Serve index.html in static middleware

This commit is contained in:
Benedikt Kulmann
2020-11-20 10:47:17 +01:00
parent 0ea04c02f9
commit d91008c3c2
+4 -8
View File
@@ -30,14 +30,10 @@ func Static(root string, fs http.FileSystem, ttl int) func(http.Handler) http.Ha
if strings.HasPrefix(r.URL.Path, path.Join(root, "api")) {
next.ServeHTTP(w, r)
} else {
if strings.HasSuffix(r.URL.Path, "/") {
http.NotFound(w, r)
} else {
w.Header().Set("Cache-Control", fmt.Sprintf("max-age=%s", strconv.Itoa(ttl)))
w.Header().Set("Last-Modified", lastModified)
w.Header().Del("Expires")
static.ServeHTTP(w, r)
}
w.Header().Set("Cache-Control", fmt.Sprintf("max-age=%s", strconv.Itoa(ttl)))
w.Header().Set("Last-Modified", lastModified)
w.Header().Del("Expires")
static.ServeHTTP(w, r)
}
})
}