Browse Source

Support admin paths with index.html (#332)

pull/333/head
Gabe Kangas 5 years ago committed by GitHub
parent
commit
00b1e06840
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 7
      controllers/admin/index.go
  2. 2
      pkged.go

7
controllers/admin/index.go

@ -16,9 +16,12 @@ func ServeAdmin(w http.ResponseWriter, r *http.Request) { @@ -16,9 +16,12 @@ func ServeAdmin(w http.ResponseWriter, r *http.Request) {
// Set a cache control max-age header
middleware.SetCachingHeaders(w, r)
// Determine if the requested path is a directory.
// If so, append index.html to the request.
path := r.URL.Path
if path == "/admin" || path == "/admin/" {
path = "/admin/index.html"
dirCheck, err := pkger.Stat(path)
if dirCheck != nil && err == nil && dirCheck.IsDir() {
path = filepath.Join(path, "index.html")
}
f, err := pkger.Open(path)

2
pkged.go

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save