Added some notes on functions I may no longer need.
This commit is contained in:
@@ -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
|
||||||
|
|||||||
@@ -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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user