quickserv

This commit is contained in:
Cadey Ratio 2020-02-08 22:06:53 +00:00
commit f281d90c7b
6 changed files with 118 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
/result-bin

13
default.nix Normal file
View File

@ -0,0 +1,13 @@
{ pkgs ? import <nixpkgs> {} }:
with pkgs;
buildGoPackage rec {
name = "quickserv";
version = "1.0.0";
goPackagePath = "tulpa.dev/Xe/quickserv";
src = ./.;
goDeps = ./deps.nix;
allowGoReference = false;
CGO_ENABLED = "0";
}

57
deps.nix Normal file
View File

@ -0,0 +1,57 @@
# file generated from go.mod using vgo2nix (https://github.com/adisbladis/vgo2nix)
[
{
goPackagePath = "github.com/davecgh/go-spew";
fetch = {
type = "git";
url = "https://github.com/davecgh/go-spew";
rev = "v1.1.1";
sha256 = "0hka6hmyvp701adzag2g26cxdj47g21x6jz4sc6jjz1mn59d474y";
};
}
{
goPackagePath = "github.com/facebookarchive/flagenv";
fetch = {
type = "git";
url = "https://github.com/facebookarchive/flagenv";
rev = "fcd59fca7456";
sha256 = "0c7fw4y4gmdrn66dx7la637lx0hvs1w27x9j12wdx037n51r078g";
};
}
{
goPackagePath = "github.com/facebookgo/ensure";
fetch = {
type = "git";
url = "https://github.com/facebookgo/ensure";
rev = "63f1cf65ac4c";
sha256 = "05vi49g2967i5awcb1z69i2n5b5hwn06682kw90x81hbxlr0px36";
};
}
{
goPackagePath = "github.com/facebookgo/flagenv";
fetch = {
type = "git";
url = "https://github.com/facebookgo/flagenv";
rev = "fcd59fca7456";
sha256 = "0c7fw4y4gmdrn66dx7la637lx0hvs1w27x9j12wdx037n51r078g";
};
}
{
goPackagePath = "github.com/facebookgo/stack";
fetch = {
type = "git";
url = "https://github.com/facebookgo/stack";
rev = "751773369052";
sha256 = "07yr05mz7h007ldpij90zjflwgixp148sbyrdlh1fj5bikr4p8m3";
};
}
{
goPackagePath = "github.com/facebookgo/subset";
fetch = {
type = "git";
url = "https://github.com/facebookgo/subset";
rev = "c811ad88dec4";
sha256 = "1sjczgmq26mgqvh7267saypnn4sfdjx467wsm1pgdhyss77mc650";
};
}
]

12
go.mod Normal file
View File

@ -0,0 +1,12 @@
module tulpa.dev/Xe/quickserv
go 1.13
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/facebookarchive/flagenv v0.0.0-20160425205200-fcd59fca7456
github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c // indirect
github.com/facebookgo/flagenv v0.0.0-20160425205200-fcd59fca7456 // indirect
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 // indirect
github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 // indirect
)

12
go.sum Normal file
View File

@ -0,0 +1,12 @@
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/facebookarchive/flagenv v0.0.0-20160425205200-fcd59fca7456 h1:1NzATV1A9LeTWAuAJGd7vE/wYSO08EJQTrwKcBBR6Cw=
github.com/facebookarchive/flagenv v0.0.0-20160425205200-fcd59fca7456/go.mod h1:Lbo+w7sC1xznzryrqUDoBBT2nLKV9JnDOzdiVMHYX/8=
github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c h1:8ISkoahWXwZR41ois5lSJBSVw4D0OV19Ht/JSTzvSv0=
github.com/facebookgo/ensure v0.0.0-20200202191622-63f1cf65ac4c/go.mod h1:Yg+htXGokKKdzcwhuNDwVvN+uBxDGXJ7G/VN1d8fa64=
github.com/facebookgo/flagenv v0.0.0-20160425205200-fcd59fca7456 h1:CkmB2l68uhvRlwOTPrwnuitSxi/S3Cg4L5QYOcL9MBc=
github.com/facebookgo/flagenv v0.0.0-20160425205200-fcd59fca7456/go.mod h1:zFhibDvPDWmtk4dAQ05sRobtyoffEHygEt3wSNuAzz8=
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052 h1:JWuenKqqX8nojtoVVWjGfOF9635RETekkoH6Cc9SX0A=
github.com/facebookgo/stack v0.0.0-20160209184415-751773369052/go.mod h1:UbMTZqLaRiH3MsBH8va0n7s1pQYcu3uTb8G4tygF4Zg=
github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4 h1:7HZCaLC5+BZpmbhCOZJ293Lz68O7PYrF2EzeiFMwCLk=
github.com/facebookgo/subset v0.0.0-20200203212716-c811ad88dec4/go.mod h1:5tD+neXqOorC30/tWg0LCSkrqj/AR6gu8yY8/fpw1q0=

23
main.go Normal file
View File

@ -0,0 +1,23 @@
// Command quickserv serves a folder of files over HTTP quickly.
package main
import (
"flag"
"log"
"net/http"
"github.com/facebookarchive/flagenv"
)
var (
port = flag.String("port", "3000", "port to use")
dir = flag.String("dir", ".", "directory to serve")
)
func main() {
flagenv.Parse()
flag.Parse()
http.Handle("/", http.FileServer(http.Dir(*dir)))
log.Printf("Serving %s on port %s", *dir, *port)
log.Fatal(http.ListenAndServe(":"+*port, nil))
}