Fixed static file embedding
This commit is contained in:
@@ -18,12 +18,13 @@ func addRoutes(
|
||||
logger *zerolog.Logger,
|
||||
config *config.Config,
|
||||
conn *sql.DB,
|
||||
staticFS *http.FileSystem,
|
||||
) {
|
||||
// Health check
|
||||
mux.HandleFunc("GET /healthz", func(http.ResponseWriter, *http.Request) {})
|
||||
|
||||
// Static files
|
||||
mux.Handle("GET /static/", http.StripPrefix("/static/", handlers.HandleStatic()))
|
||||
mux.Handle("GET /static/", http.StripPrefix("/static/", handlers.HandleStatic(staticFS)))
|
||||
|
||||
// Index page and unhandled catchall (404)
|
||||
mux.Handle("GET /", handlers.HandleRoot())
|
||||
|
||||
@@ -15,6 +15,7 @@ func NewServer(
|
||||
config *config.Config,
|
||||
logger *zerolog.Logger,
|
||||
conn *sql.DB,
|
||||
staticFS *http.FileSystem,
|
||||
) http.Handler {
|
||||
mux := http.NewServeMux()
|
||||
addRoutes(
|
||||
@@ -22,6 +23,7 @@ func NewServer(
|
||||
logger,
|
||||
config,
|
||||
conn,
|
||||
staticFS,
|
||||
)
|
||||
var handler http.Handler = mux
|
||||
// Add middleware here, must be added in reverse order of execution
|
||||
@@ -29,10 +31,6 @@ func NewServer(
|
||||
handler = middleware.Logging(logger, handler)
|
||||
handler = middleware.Authentication(logger, config, conn, handler)
|
||||
|
||||
// Serve the favicon and exluded files before any middleware is added
|
||||
handler = middleware.ExcludedFiles(handler)
|
||||
handler = middleware.Favicon(handler)
|
||||
|
||||
// Gzip
|
||||
handler = middleware.Gzip(handler, config.GZIP)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user