✨ add comment and reply framework
This commit is contained in:
12
router/modules/comment_router.go
Normal file
12
router/modules/comment_router.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package modules
|
||||
|
||||
import (
|
||||
"github.com/gin-gonic/gin"
|
||||
"schisandra-cloud-album/api"
|
||||
)
|
||||
|
||||
var commonApi = api.Api.CommonApi
|
||||
|
||||
func CommentRouter(router *gin.RouterGroup) {
|
||||
router.POST("/auth/comment/submit", commonApi.CommentSubmit)
|
||||
}
|
@@ -2,9 +2,7 @@ package router
|
||||
|
||||
import (
|
||||
"github.com/gin-contrib/cors"
|
||||
ginI18n "github.com/gin-contrib/i18n"
|
||||
"github.com/gin-gonic/gin"
|
||||
"schisandra-cloud-album/common/result"
|
||||
"schisandra-cloud-album/global"
|
||||
"schisandra-cloud-album/middleware"
|
||||
"schisandra-cloud-album/router/modules"
|
||||
@@ -14,8 +12,6 @@ import (
|
||||
func InitRouter() *gin.Engine {
|
||||
gin.SetMode(global.CONFIG.System.Env)
|
||||
router := gin.Default()
|
||||
router.NoRoute(HandleNotFound)
|
||||
router.NoMethod(HandleNotFound)
|
||||
err := router.SetTrustedProxies([]string{global.CONFIG.System.Ip})
|
||||
if err != nil {
|
||||
global.LOG.Error(err)
|
||||
@@ -33,7 +29,7 @@ func InitRouter() *gin.Engine {
|
||||
// 国际化设置
|
||||
router.Use(middleware.I18n())
|
||||
|
||||
noMiddlewareRouter := router.Group("api")
|
||||
noMiddlewareRouter := router.Group("api") // 不需要中间件的路由组
|
||||
{
|
||||
modules.WebsocketRouter(noMiddlewareRouter) // 注册websocket路由
|
||||
modules.OauthRouter(noMiddlewareRouter) // 注册oauth路由
|
||||
@@ -48,24 +44,19 @@ func InitRouter() *gin.Engine {
|
||||
modules.SmsRouter(publicGroup) // 注册短信验证码路由
|
||||
modules.UserRouter(publicGroup) // 注册鉴权路由
|
||||
}
|
||||
authGroup := router.Group("api") // 需要鉴权的路由组
|
||||
|
||||
authGroup := router.Group("api") // 需要鉴权的路由组
|
||||
authGroup.Use(
|
||||
middleware.SecurityHeaders(),
|
||||
middleware.JWTAuthMiddleware(),
|
||||
middleware.CasbinMiddleware(),
|
||||
middleware.SecurityHeaders(),
|
||||
)
|
||||
{
|
||||
modules.UserRouterAuth(authGroup) // 注册鉴权路由
|
||||
modules.RoleRouter(authGroup) // 注册角色路由
|
||||
modules.PermissionRouter(authGroup) // 注册权限路由
|
||||
modules.CommentRouter(authGroup) // 注册评论路由
|
||||
}
|
||||
|
||||
return router
|
||||
}
|
||||
|
||||
// HandleNotFound 404处理
|
||||
func HandleNotFound(c *gin.Context) {
|
||||
result.FailWithCodeAndMessage(404, ginI18n.MustGetMessage(c, "404NotFound"), c)
|
||||
return
|
||||
}
|
||||
|
Reference in New Issue
Block a user