1
0

Made use of httpr.Router.Sub() functionality.

This commit is contained in:
Alexander Andreev 2023-08-12 23:52:52 +04:00
parent 6fe6c856cd
commit a6bec0db75
Signed by: Arav
GPG Key ID: D22A817D95815393

View File

@ -96,27 +96,30 @@ func main() {
captchaApi := dwhttp.NewCaptchaApiHandlers(*captchaExpiry)
r.Handler(http.MethodPost, "/api/captcha", captchaApi.New)
r.Handler(http.MethodPost, "/api/captcha/:id", captchaApi.Solve)
r.Handler(http.MethodGet, "/api/captcha/:id/image", captchaApi.Image)
s := r.Sub("/api/captcha")
s.Handler(http.MethodPost, "/", captchaApi.New)
s.Handler(http.MethodPost, "/:id", captchaApi.Solve)
s.Handler(http.MethodGet, "/:id/image", captchaApi.Image)
guestbookApi := dwhttp.NewGuestbookApiHandlers(*guestbookOwner, *guestbookPageSize, guestbookDB)
r.Handler(http.MethodPost, "/api/guestbook", guestbookApi.New)
r.Handler(http.MethodPatch, "/api/guestbook/:id", guestbookApi.Edit)
r.Handler(http.MethodDelete, "/api/guestbook/:id", guestbookApi.Delete)
r.Handler(http.MethodPost, "/api/guestbook/:id/reply", guestbookApi.Reply)
r.Handler(http.MethodPatch, "/api/guestbook/:id/reply", guestbookApi.EditReply)
r.Handler(http.MethodDelete, "/api/guestbook/:id/reply", guestbookApi.DeleteReply)
s = r.Sub("/api/guestbook")
s.Handler(http.MethodPost, "/", guestbookApi.New)
s.Handler(http.MethodPatch, "/:id", guestbookApi.Edit)
s.Handler(http.MethodDelete, "/:id", guestbookApi.Delete)
s.Handler(http.MethodPost, "/:id/reply", guestbookApi.Reply)
s.Handler(http.MethodPatch, "/:id/reply", guestbookApi.EditReply)
s.Handler(http.MethodDelete, "/:id/reply", guestbookApi.DeleteReply)
mindflowApi := dwhttp.NewMindflowApiHandlers(mindflowDB)
r.Handler(http.MethodPost, "/api/mindflow", mindflowApi.NewPost)
r.Handler(http.MethodPatch, "/api/mindflow/:id", mindflowApi.EditPost)
r.Handler(http.MethodDelete, "/api/mindflow/:id", mindflowApi.DeletePost)
r.Handler(http.MethodPost, "/api/mindflow/category", mindflowApi.NewCategory)
r.Handler(http.MethodPatch, "/api/mindflow/category/:id", mindflowApi.EditCategory)
r.Handler(http.MethodDelete, "/api/mindflow/category/:id", mindflowApi.DeleteCategory)
s = r.Sub("/api/mindflow")
s.Handler(http.MethodPost, "/", mindflowApi.NewPost)
s.Handler(http.MethodPatch, "/:id", mindflowApi.EditPost)
s.Handler(http.MethodDelete, "/:id", mindflowApi.DeletePost)
s.Handler(http.MethodPost, "/category", mindflowApi.NewCategory)
s.Handler(http.MethodPatch, "/category/:id", mindflowApi.EditCategory)
s.Handler(http.MethodDelete, "/category/:id", mindflowApi.DeleteCategory)
srv := dwhttp.NewHttpServer(r)