diff --git a/CLAUDE.md b/CLAUDE.md deleted file mode 100644 index c0fa912..0000000 --- a/CLAUDE.md +++ /dev/null @@ -1,27 +0,0 @@ -# CLAUDE.md - Member Console Guidelines - -## Build & Run Commands -- Build: `go build -o member-console` -- Run: `go run main.go start` -- Run with config: `go run main.go start --config path/to/config.yaml` -- Test: `go test ./...` -- Test specific: `go test ./internal/auth` -- Lint: `golangci-lint run` - -## Code Style Guidelines -- **Formatting**: Standard Go formatting with `gofmt` -- **Imports**: Group by standard lib, then external, then internal -- **Naming**: - - Packages: lowercase, single word - - Exported functions: PascalCase - - Internal functions: camelCase - - Variables: camelCase -- **Error Handling**: Check errors with `if err != nil`, use descriptive messages -- **Security**: Implement secure headers, CSRF protection, proper session management -- **Documentation**: Comment all exported functions and types -- **Configuration**: Use Viper with env vars (WCMC prefix) - -## Architecture -- Clean separation of concerns (middleware, auth, handlers) -- Follow Go project layout standards -- Protected routes should implement CSRF protection \ No newline at end of file diff --git a/internal/server/server.go b/internal/server/server.go index 469e33b..edf6c2f 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -2,6 +2,7 @@ package server import ( "context" + "io/fs" "log/slog" "net" "net/http" @@ -87,11 +88,16 @@ 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 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)))) + // For embedded templates + templateSubFS, err := fs.Sub(embeds.Templates, "templates") + if err != nil { + cfg.Logger.Error("Failed to create sub filesystem for templates", slog.Any("error", err)) + return err + } + httpRequestRouter.Handle("/", http.FileServer(http.FS(templateSubFS))) + + // For embedded static files + httpRequestRouter.Handle("/static/", http.FileServer(http.FS(embeds.Static))) // Log server startup with structured logging cfg.Logger.Info("starting server",