Skip to content

Commit

Permalink
Merge pull request #912 from owncloud/serve-index-html
Browse files Browse the repository at this point in the history
Serve index html
  • Loading branch information
kulmann authored Nov 20, 2020
2 parents 2069802 + 54f9505 commit b8fee3f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
6 changes: 6 additions & 0 deletions changelog/unreleased/pkg-serve-index-html.md
Original file line number Diff line number Diff line change
@@ -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
12 changes: 4 additions & 8 deletions ocis-pkg/middleware/static.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
})
}
Expand Down

0 comments on commit b8fee3f

Please sign in to comment.