main.go: reload frontend on F5

pull/2/head
leonnicolas 4 years ago
parent 9ecad37f80
commit 6091903ed7
No known key found for this signature in database
GPG Key ID: 088D0743E2B65C07

@ -3,19 +3,28 @@ package main
import (
"log"
"net/http"
"strings"
"github.com/rakyll/statik/fs"
_ "github.com/fLotte-meets-HWR-DB/frontend/statik"
)
func strip(handler http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
if !strings.Contains(r.URL.Path, ".") {
r.URL.Path = "/"
}
handler.ServeHTTP(w, r)
})
}
func main() {
statikFS, err := fs.New()
if err != nil {
log.Fatal(err)
}
// Serve the contents over HTTP.
http.Handle("/", http.FileServer(statikFS))
log.Fatal(http.ListenAndServe(":8080", nil))
m := http.NewServeMux()
m.Handle("/", strip(http.FileServer(statikFS)))
log.Fatal(http.ListenAndServe(":8080", m))
}

Loading…
Cancel
Save