added comments

This commit is contained in:
u80864958
2025-05-02 10:39:35 +02:00
parent fb7d5a623a
commit 14b57b57e8
16 changed files with 73 additions and 29 deletions

View File

@ -11,6 +11,7 @@ import (
"github.com/gorilla/mux"
)
// CreateMux creates and configures a mux router with authentication and post-related routes.
func CreateMux(cfg *config.Config) (r *mux.Router) {
db := model.Init()
blg := posts.New(db)
@ -22,7 +23,7 @@ func CreateMux(cfg *config.Config) (r *mux.Router) {
// auth
r.HandleFunc("/login", auth.Login).Methods("POST")
r.HandleFunc("/signup", auth.Signup).Methods("POST")
r.Handle("logout", auth.Authenticated(auth.Logout)).Methods("POST")
r.Handle("/logout", auth.Authenticated(auth.Logout)).Methods("DELETE")
// Posts
r.Handle("/posts", auth.Authenticated(blg.SavePost, model.RoleUser, model.RoleAdmin)).Methods("POST")