This repository has been archived on 2023-07-09. You can view files and clone it, but cannot push or open issues or pull requests.
sudoscientist-go-backend/packages/blog/routes.go

33 lines
928 B
Go

package blog
import (
"git.minhas.io/asara/sudoscientist-go-backend/packages/middleware"
"github.com/go-chi/chi"
"github.com/go-chi/jwtauth"
)
func Routes() *chi.Mux {
r := chi.NewRouter()
r.Group(func(r chi.Router) {
r.Use(jwtauth.Verify(TokenAuth, auth_middleware.TokenFromSplitCookie))
r.Use(jwtauth.Authenticator)
r.Post("/posts", createBlogPost)
r.Patch("/posts/by-id/{id}", updateBlogPostById)
r.Post("/comments/{post_id}", postComment)
/*
r.Patch("/comments/{id}", updateComment)
*/
})
r.Get("/posts", getBlogPosts)
r.Get("/posts/by-id/{id}", getBlogPostById)
r.Get("/posts/by-tag/{tag}", getBlogPostsByTag)
r.Get("/posts/by-author/{author}", getBlogPostsByAuthor)
r.Get("/posts/by-slug/{slug}", getBlogPostBySlug)
r.Get("/comments/{post_id}", getCommentsByParentId)
/*
r.Get("/by-author/{author}", getCommentsByAuthor)
r.Get("/by-parent/{post_id}", getCommentsByPost)
*/
return r
}