package web import ( "net/http" "path/filepath" assetfs "github.com/elazarl/go-bindata-assetfs" ) //go:generate go get github.com/jteeuwen/go-bindata/... //go:generate go get github.com/elazarl/go-bindata-assetfs/... //go:generate rm -f static.go //go:generate go-bindata -o static.go -pkg=web static/... func NewServer(sm *http.ServeMux, static string) { var fs http.FileSystem if p, d := filepath.Split(static); d == "static" { static = p } fs = http.Dir(static) if static == "" { fs = &assetfs.AssetFS{ Asset: Asset, AssetDir: AssetDir, AssetInfo: AssetInfo, Prefix: "static", } } sm.Handle( "/", http.FileServer(fs), ) }