Added some notes on functions I may no longer need.

This commit is contained in:
2026-04-29 09:19:19 +02:00
parent e5537a76d3
commit 502b2abb2b
2 changed files with 13 additions and 5 deletions
+6 -5
View File
@@ -13,6 +13,7 @@ func (s *Server) setupRoutes() *chi.Mux {
router.Use(middleware.Logger) router.Use(middleware.Logger)
router.Use(middleware.Recoverer) router.Use(middleware.Recoverer)
// TODO: Not sure this is needed right now
// Setup basic file server nothing fancy // Setup basic file server nothing fancy
router.Handle("/static/*", http.StripPrefix("/static", http.FileServer(http.Dir("static")))) 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("/register", s.handleRegister())
router.Post("/login", s.handleLogin()) router.Post("/login", s.handleLogin())
router.Post("/logout", s.handleLogout()) router.Post("/logout", s.handleLogout())
// public pages
r.Get("/", s.handleHome())
}) })
// User routes // Private routes
router.Group(func(r chi.Router) { router.Group(func(r chi.Router) {
// Requires log in // Requires log in
r.Use(s.hasAuth) 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 return router
+7
View File
@@ -1,11 +1,18 @@
package web package web
import ( import (
"context"
"html/template" "html/template"
"net/http" "net/http"
"path/filepath" "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 // 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 // Parsed together so the page can define blocks needed for base template
func render(w http.ResponseWriter, _ *http.Request, page string, data any) { func render(w http.ResponseWriter, _ *http.Request, page string, data any) {