Merge pull request #912 from owncloud/serve-index-html
Serve index html
This commit is contained in:
@@ -0,0 +1,6 @@
|
|||||||
|
Bugfix: Serve index.html for directories
|
||||||
|
|
||||||
|
The static middleware in ocis-pkg now serves index.html instead of returning 404 on paths with a trailing `/`.
|
||||||
|
|
||||||
|
https://github.com/owncloud/ocis/pull/912
|
||||||
|
https://github.com/owncloud/ocis-pkg/issues/63
|
||||||
@@ -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")) {
|
if strings.HasPrefix(r.URL.Path, path.Join(root, "api")) {
|
||||||
next.ServeHTTP(w, r)
|
next.ServeHTTP(w, r)
|
||||||
} else {
|
} else {
|
||||||
if strings.HasSuffix(r.URL.Path, "/") {
|
w.Header().Set("Cache-Control", fmt.Sprintf("max-age=%s", strconv.Itoa(ttl)))
|
||||||
http.NotFound(w, r)
|
w.Header().Set("Last-Modified", lastModified)
|
||||||
} else {
|
w.Header().Del("Expires")
|
||||||
w.Header().Set("Cache-Control", fmt.Sprintf("max-age=%s", strconv.Itoa(ttl)))
|
static.ServeHTTP(w, r)
|
||||||
w.Header().Set("Last-Modified", lastModified)
|
|
||||||
w.Header().Del("Expires")
|
|
||||||
static.ServeHTTP(w, r)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user