From 502b2abb2b42b9998620a106cea5bb4c986a017b Mon Sep 17 00:00:00 2001 From: Jason Hilder Date: Wed, 29 Apr 2026 09:19:19 +0200 Subject: [PATCH] Added some notes on functions I may no longer need. --- internal/web/routes.go | 11 ++++++----- internal/web/utils.go | 7 +++++++ 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/internal/web/routes.go b/internal/web/routes.go index 5fc3139..b595f6e 100644 --- a/internal/web/routes.go +++ b/internal/web/routes.go @@ -13,6 +13,7 @@ func (s *Server) setupRoutes() *chi.Mux { router.Use(middleware.Logger) router.Use(middleware.Recoverer) + // TODO: Not sure this is needed right now // Setup basic file server nothing fancy router.Handle("/static/*", http.StripPrefix("/static", http.FileServer(http.Dir("static")))) @@ -22,16 +23,16 @@ func (s *Server) setupRoutes() *chi.Mux { router.Post("/register", s.handleRegister()) router.Post("/login", s.handleLogin()) router.Post("/logout", s.handleLogout()) - - // public pages - r.Get("/", s.handleHome()) }) - // User routes + // Private routes router.Group(func(r chi.Router) { // Requires log in r.Use(s.hasAuth) - router.Mount("/users", s.userRoutes()) + + // TODO add authenicated routes here + // r.Get("/", s.handleHome()) + // router.Mount("/users", s.userRoutes()) }) return router diff --git a/internal/web/utils.go b/internal/web/utils.go index 6f10d9a..9573613 100644 --- a/internal/web/utils.go +++ b/internal/web/utils.go @@ -1,11 +1,18 @@ package web import ( + "context" "html/template" "net/http" "path/filepath" ) +func userIDFromContext(ctx context.Context) (string, bool) { + id, ok := ctx.Value(userIDKey).(string) + return id, ok +} + +// TODO: Not sure this is needed right now // Renders a full page by combining the base template with a page template // Parsed together so the page can define blocks needed for base template func render(w http.ResponseWriter, _ *http.Request, page string, data any) {