|
|
@ -3,19 +3,28 @@ package main
|
|
|
|
import (
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
"log"
|
|
|
|
"net/http"
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"strings"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/rakyll/statik/fs"
|
|
|
|
"github.com/rakyll/statik/fs"
|
|
|
|
|
|
|
|
|
|
|
|
_ "github.com/fLotte-meets-HWR-DB/frontend/statik"
|
|
|
|
_ "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() {
|
|
|
|
func main() {
|
|
|
|
statikFS, err := fs.New()
|
|
|
|
statikFS, err := fs.New()
|
|
|
|
if err != nil {
|
|
|
|
if err != nil {
|
|
|
|
log.Fatal(err)
|
|
|
|
log.Fatal(err)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Serve the contents over HTTP.
|
|
|
|
m := http.NewServeMux()
|
|
|
|
http.Handle("/", http.FileServer(statikFS))
|
|
|
|
m.Handle("/", strip(http.FileServer(statikFS)))
|
|
|
|
log.Fatal(http.ListenAndServe(":8080", nil))
|
|
|
|
log.Fatal(http.ListenAndServe(":8080", m))
|
|
|
|
}
|
|
|
|
}
|
|
|
|