Makes the dev file built more gulp-ish way
This commit is contained in:
10
router.go
10
router.go
@@ -19,7 +19,7 @@ import (
|
||||
"golang.org/x/net/context"
|
||||
)
|
||||
|
||||
func (a *appData) buildRouter() http.Handler {
|
||||
func (a *appData) buildRouter(basepath string) http.Handler {
|
||||
router := httprouter.New()
|
||||
|
||||
logger := narco.NewLogger()
|
||||
@@ -126,19 +126,19 @@ func (a *appData) buildRouter() http.Handler {
|
||||
|
||||
})))
|
||||
|
||||
dirs := []string{"css", "js", "img", "bower_components", "html"}
|
||||
dirs := []string{"css", "js", "vendor", "html"}
|
||||
for _, d := range dirs {
|
||||
router.ServeFiles(path.Join("/", d, "/*filepath"), http.Dir(filepath.Join("webapp", d)))
|
||||
router.ServeFiles(path.Join("/", d, "/*filepath"), http.Dir(filepath.Join(basepath, d)))
|
||||
}
|
||||
|
||||
router.GET("/", narco.EndChain(ch, narco.HandlerFunc(
|
||||
func(ctx context.Context, w http.ResponseWriter, req *http.Request, _ httprouter.Params) {
|
||||
f, err := os.Open(filepath.Join("webapp", "index.html"))
|
||||
f, err := os.Open(filepath.Join(basepath, "index.html"))
|
||||
if err != nil {
|
||||
narco.Error(ctx, w, err, http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
defer closeOrPanic(f, filepath.Join("webapp", "index.html"))
|
||||
defer closeOrPanic(f, filepath.Join(basepath, "index.html"))
|
||||
|
||||
_, err = io.Copy(w, f)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user