0

Support admin paths with index.html (#332)

This commit is contained in:
Gabe Kangas 2020-11-09 19:52:43 -08:00 committed by GitHub
parent 73ec2126cc
commit 00b1e06840
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View File

@ -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)

File diff suppressed because one or more lines are too long