This commit is contained in:
@@ -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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user