refactor: 将redis提取到middleware文件夹
This commit is contained in:
@@ -3,8 +3,8 @@ package http
|
||||
import (
|
||||
"feedsystem_video_go/internal/account"
|
||||
"feedsystem_video_go/internal/feed"
|
||||
"feedsystem_video_go/internal/middleware"
|
||||
rediscache "feedsystem_video_go/internal/redis"
|
||||
"feedsystem_video_go/internal/middleware/jwt"
|
||||
rediscache "feedsystem_video_go/internal/middleware/redis"
|
||||
"feedsystem_video_go/internal/social"
|
||||
"feedsystem_video_go/internal/video"
|
||||
|
||||
@@ -28,7 +28,7 @@ func SetRouter(db *gorm.DB, cache *rediscache.Client) *gin.Engine {
|
||||
accountGroup.POST("/findByUsername", accountHandler.FindByUsername)
|
||||
}
|
||||
protectedAccountGroup := accountGroup.Group("")
|
||||
protectedAccountGroup.Use(middleware.JWTAuth(accountRepository, cache))
|
||||
protectedAccountGroup.Use(jwt.JWTAuth(accountRepository, cache))
|
||||
{
|
||||
protectedAccountGroup.POST("/logout", accountHandler.Logout)
|
||||
protectedAccountGroup.POST("/rename", accountHandler.Rename)
|
||||
@@ -43,7 +43,7 @@ func SetRouter(db *gorm.DB, cache *rediscache.Client) *gin.Engine {
|
||||
videoGroup.POST("/getDetail", videoHandler.GetDetail)
|
||||
}
|
||||
protectedVideoGroup := videoGroup.Group("")
|
||||
protectedVideoGroup.Use(middleware.JWTAuth(accountRepository, cache))
|
||||
protectedVideoGroup.Use(jwt.JWTAuth(accountRepository, cache))
|
||||
{
|
||||
protectedVideoGroup.POST("/uploadVideo", videoHandler.UploadVideo)
|
||||
protectedVideoGroup.POST("/uploadCover", videoHandler.UploadCover)
|
||||
@@ -55,7 +55,7 @@ func SetRouter(db *gorm.DB, cache *rediscache.Client) *gin.Engine {
|
||||
likeHandler := video.NewLikeHandler(likeService, videoService)
|
||||
likeGroup := r.Group("/like")
|
||||
protectedLikeGroup := likeGroup.Group("")
|
||||
protectedLikeGroup.Use(middleware.JWTAuth(accountRepository, cache))
|
||||
protectedLikeGroup.Use(jwt.JWTAuth(accountRepository, cache))
|
||||
{
|
||||
protectedLikeGroup.POST("/like", likeHandler.Like)
|
||||
protectedLikeGroup.POST("/unlike", likeHandler.Unlike)
|
||||
@@ -71,7 +71,7 @@ func SetRouter(db *gorm.DB, cache *rediscache.Client) *gin.Engine {
|
||||
commentGroup.POST("/listAll", commentHandler.GetAllComments)
|
||||
}
|
||||
protectedCommentGroup := commentGroup.Group("")
|
||||
protectedCommentGroup.Use(middleware.JWTAuth(accountRepository, cache))
|
||||
protectedCommentGroup.Use(jwt.JWTAuth(accountRepository, cache))
|
||||
{
|
||||
protectedCommentGroup.POST("/publish", commentHandler.PublishComment)
|
||||
protectedCommentGroup.POST("/delete", commentHandler.DeleteComment)
|
||||
@@ -82,7 +82,7 @@ func SetRouter(db *gorm.DB, cache *rediscache.Client) *gin.Engine {
|
||||
socialHandler := social.NewSocialHandler(socialService)
|
||||
socialGroup := r.Group("/social")
|
||||
protectedSocialGroup := socialGroup.Group("")
|
||||
protectedSocialGroup.Use(middleware.JWTAuth(accountRepository, cache))
|
||||
protectedSocialGroup.Use(jwt.JWTAuth(accountRepository, cache))
|
||||
{
|
||||
protectedSocialGroup.POST("/follow", socialHandler.Follow)
|
||||
protectedSocialGroup.POST("/unfollow", socialHandler.Unfollow)
|
||||
@@ -94,14 +94,14 @@ func SetRouter(db *gorm.DB, cache *rediscache.Client) *gin.Engine {
|
||||
feedService := feed.NewFeedService(feedRepository, likeRepository, cache)
|
||||
feedHandler := feed.NewFeedHandler(feedService)
|
||||
feedGroup := r.Group("/feed")
|
||||
feedGroup.Use(middleware.SoftJWTAuth(accountRepository, cache))
|
||||
feedGroup.Use(jwt.SoftJWTAuth(accountRepository, cache))
|
||||
{
|
||||
feedGroup.POST("/listLatest", feedHandler.ListLatest)
|
||||
feedGroup.POST("/listLikesCount", feedHandler.ListLikesCount)
|
||||
feedGroup.POST("/listByPopularity", feedHandler.ListByPopularity)
|
||||
}
|
||||
protectedFeedGroup := feedGroup.Group("")
|
||||
protectedFeedGroup.Use(middleware.JWTAuth(accountRepository, cache))
|
||||
protectedFeedGroup.Use(jwt.JWTAuth(accountRepository, cache))
|
||||
{
|
||||
protectedFeedGroup.POST("/listByFollowing", feedHandler.ListByFollowing)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user