Server serves default content using go embed. Also add favicons/
This commit is contained in:
@ -8,6 +8,7 @@ import (
|
||||
"time"
|
||||
|
||||
"git.coopcloud.tech/wiki-cafe/member-console/internal/auth"
|
||||
"git.coopcloud.tech/wiki-cafe/member-console/internal/embeds"
|
||||
"git.coopcloud.tech/wiki-cafe/member-console/internal/middleware"
|
||||
"github.com/rs/cors"
|
||||
)
|
||||
@ -86,11 +87,11 @@ func Start(ctx context.Context, cfg Config) error {
|
||||
BaseContext: func(_ net.Listener) context.Context { return ctx }, // Pass base context to all requests
|
||||
}
|
||||
|
||||
// Serve the templates and static files
|
||||
// Serve templates from the "templates" directory
|
||||
httpRequestRouter.Handle("/", http.FileServer(http.Dir("./templates")))
|
||||
// Serve static files from the "static" directory
|
||||
httpRequestRouter.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("./static"))))
|
||||
// Serve the templates and static files using embedded content
|
||||
// Serve templates from the embedded "templates" directory
|
||||
httpRequestRouter.Handle("/", http.FileServer(http.FS(embeds.Templates)))
|
||||
// Serve static files from the embedded "static" directory
|
||||
httpRequestRouter.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.FS(embeds.Static))))
|
||||
|
||||
// Log server startup with structured logging
|
||||
cfg.Logger.Info("starting server",
|
||||
|
Reference in New Issue
Block a user