rollback: go:embed for static files

This commit is contained in:
ari melody 2025-10-21 23:37:31 +01:00
parent 70b329c902
commit ef3f3c5428
Signed by: ari
GPG key ID: CF99829C92678188
5 changed files with 15 additions and 11 deletions

View file

@ -3,13 +3,9 @@ package admin
import (
"context"
"database/sql"
"embed"
"fmt"
"mime"
"net/http"
"os"
"path"
"path/filepath"
"strings"
"time"
@ -17,6 +13,7 @@ import (
"arimelody-web/controller"
"arimelody-web/log"
"arimelody-web/model"
"arimelody-web/view"
"golang.org/x/crypto/bcrypt"
)
@ -58,7 +55,9 @@ func Handler(app *model.AppState) http.Handler {
mux.Handle("/tracks", requireAccount(serveTracks(app)))
mux.Handle("/tracks/", requireAccount(serveTracks(app)))
mux.Handle("/static/", staticHandler())
mux.Handle("/static/", requireAccount(
http.StripPrefix("/static",
view.ServeFiles("./admin/static"))))
mux.Handle("/", requireAccount(AdminIndexHandler(app)))
@ -484,6 +483,7 @@ func requireAccount(next http.Handler) http.HandlerFunc {
})
}
/*
//go:embed "static"
var staticFS embed.FS
@ -502,6 +502,7 @@ func staticHandler() http.Handler {
w.Write(file)
})
}
*/
func enforceSession(app *model.AppState, next http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {