Add file mime type check & switch usercard errors to modal

This commit is contained in:
Marco Realacci 2022-12-12 22:53:34 +01:00
parent 4cad313aaa
commit 6840c34d7b
3 changed files with 56 additions and 13 deletions

View file

@ -4,10 +4,11 @@ package main
import (
"fmt"
"github.com/notherealmarco/WASAPhoto/webui"
"io/fs"
"net/http"
"strings"
"github.com/notherealmarco/WASAPhoto/webui"
)
func registerWebUI(hdl http.Handler) (http.Handler, error) {
@ -20,6 +21,10 @@ func registerWebUI(hdl http.Handler) (http.Handler, error) {
if strings.HasPrefix(r.RequestURI, "/dashboard/") {
http.StripPrefix("/dashboard/", http.FileServer(http.FS(distDirectory))).ServeHTTP(w, r)
return
} else if r.RequestURI == "/" {
// Redirect to dashboard
http.Redirect(w, r, "/dashboard/", http.StatusTemporaryRedirect)
return
}
hdl.ServeHTTP(w, r)
}), nil