feat: private posts
All checks were successful
Release / publish (push) Successful in 2m41s

This commit is contained in:
2025-10-17 23:51:19 +02:00
parent 68574ad289
commit 893c49ec88
15 changed files with 154 additions and 15 deletions

View File

@@ -26,7 +26,7 @@ func CreateMux(cfg *config.Config) (r *mux.Router) {
w.WriteHeader(http.StatusNoContent)
})
return
return r
}
func frontend(r *mux.Route) {
@@ -51,12 +51,13 @@ func app(r *mux.Router, cfg *config.Config) {
// auth
r.HandleFunc("/auth/login", auth.Login).Methods("POST")
r.HandleFunc("/auth/signup", auth.Signup).Methods("POST")
r.Handle("/auth/password", auth.Authenticated(auth.ChangePassword)).Methods("PUT")
r.Handle("/auth/logout", auth.Authenticated(auth.Logout)).Methods("DELETE")
r.Handle("/auth/password", auth.Authenticated(auth.ChangePassword, true)).Methods("PUT")
r.Handle("/auth/logout", auth.Authenticated(auth.Logout, true)).Methods("DELETE")
// Posts
r.Handle("/posts", auth.Authenticated(blg.SavePost, model.RoleUser, model.RoleAdmin)).Methods("POST")
r.Handle("/posts", auth.Authenticated(blg.SavePost, model.RoleUser, model.RoleAdmin)).Methods("PUT")
r.Handle("/posts/{postID}", auth.Authenticated(blg.DeletePost, model.RoleUser, model.RoleAdmin)).Methods("DELETE")
r.Handle("/posts", http.HandlerFunc(blg.GetAllPosts)).Methods("GET")
r.Handle("/posts", auth.Authenticated(blg.SavePost, true, model.RoleUser, model.RoleAdmin)).Methods("POST")
r.Handle("/posts", auth.Authenticated(blg.SavePost, true, model.RoleUser, model.RoleAdmin)).Methods("PUT")
r.Handle("/posts/{postID}", auth.Authenticated(blg.DeletePost, true, model.RoleUser, model.RoleAdmin)).Methods("DELETE")
r.Handle("/posts", auth.Authenticated(blg.GetAllPosts, false)).Methods("GET")
r.Handle("/posts/secret/{secret}", http.HandlerFunc(blg.GetPostBySecret)).Methods("GET")
}