Makes the dev file built more gulp-ish way

This commit is contained in:
2016-02-23 18:22:21 +01:00
parent 603943c4a1
commit 924ea137b9
6 changed files with 97 additions and 28 deletions

View File

@@ -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 {