box-o-sand/oldstuff/vuefun/app.go

34 lines
597 B
Go
Raw Normal View History

2019-03-10 00:37:28 +00:00
package main
2019-07-11 23:12:14 +00:00
import (
"flag"
2019-11-06 16:18:20 +00:00
"fmt"
2019-07-11 23:12:14 +00:00
"io"
"net/http"
"github.com/urfave/negroni"
)
var (
2019-11-06 16:18:20 +00:00
addrFlag = flag.String("a", ":9745", "addr at which to listen")
distDir = flag.String("d", "dist", "directory in which are the dist bits")
2019-07-11 23:12:14 +00:00
)
2019-03-10 00:37:28 +00:00
func main() {
2019-07-11 23:12:14 +00:00
flag.Parse()
mux := http.NewServeMux()
mux.HandleFunc(`/api/`, func(w http.ResponseWriter, req *http.Request) {
io.WriteString(w, "welp")
})
n := negroni.New()
2019-11-06 16:18:20 +00:00
n.Use(negroni.NewStatic(http.Dir(*distDir)))
2019-07-11 23:12:14 +00:00
n.Use(negroni.NewLogger())
n.UseHandler(mux)
2019-11-06 16:18:20 +00:00
fmt.Printf("Serving at %v\n", *addrFlag)
2019-07-11 23:12:14 +00:00
http.ListenAndServe(*addrFlag, n)
2019-03-10 00:37:28 +00:00
}