34 lines
597 B
Go
34 lines
597 B
Go
package main
|
|
|
|
import (
|
|
"flag"
|
|
"fmt"
|
|
"io"
|
|
"net/http"
|
|
|
|
"github.com/urfave/negroni"
|
|
)
|
|
|
|
var (
|
|
addrFlag = flag.String("a", ":9745", "addr at which to listen")
|
|
distDir = flag.String("d", "dist", "directory in which are the dist bits")
|
|
)
|
|
|
|
func main() {
|
|
flag.Parse()
|
|
|
|
mux := http.NewServeMux()
|
|
|
|
mux.HandleFunc(`/api/`, func(w http.ResponseWriter, req *http.Request) {
|
|
io.WriteString(w, "welp")
|
|
})
|
|
|
|
n := negroni.New()
|
|
n.Use(negroni.NewStatic(http.Dir(*distDir)))
|
|
n.Use(negroni.NewLogger())
|
|
n.UseHandler(mux)
|
|
|
|
fmt.Printf("Serving at %v\n", *addrFlag)
|
|
http.ListenAndServe(*addrFlag, n)
|
|
}
|