mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 13:36:09 +05:00
Refactor auth code
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"server/web/auth"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
@@ -8,15 +10,17 @@ type requestI struct {
|
||||
Action string `json:"action,omitempty"`
|
||||
}
|
||||
|
||||
func SetupRoute(route *gin.RouterGroup) {
|
||||
route.GET("/shutdown", shutdown)
|
||||
func SetupRoute(route gin.IRouter) {
|
||||
authorized := route.Group("/", auth.CheckAuth())
|
||||
|
||||
route.POST("/settings", settings)
|
||||
authorized.GET("/shutdown", shutdown)
|
||||
|
||||
route.POST("/torrents", torrents)
|
||||
route.POST("/torrent/upload", torrentUpload)
|
||||
authorized.POST("/settings", settings)
|
||||
|
||||
route.POST("/cache", cache)
|
||||
authorized.POST("/torrents", torrents)
|
||||
authorized.POST("/torrent/upload", torrentUpload)
|
||||
|
||||
authorized.POST("/cache", cache)
|
||||
|
||||
route.HEAD("/stream", stream)
|
||||
route.HEAD("/stream/*fname", stream)
|
||||
@@ -27,15 +31,15 @@ func SetupRoute(route *gin.RouterGroup) {
|
||||
route.HEAD("/play/:hash/:id", play)
|
||||
route.GET("/play/:hash/:id", play)
|
||||
|
||||
route.POST("/viewed", viewed)
|
||||
authorized.POST("/viewed", viewed)
|
||||
|
||||
route.GET("/playlistall/all.m3u", allPlayList)
|
||||
authorized.GET("/playlistall/all.m3u", allPlayList)
|
||||
route.GET("/playlist", playList)
|
||||
route.GET("/playlist/*fname", playList) // Is this endpoint still needed ? `fname` is never used in handler
|
||||
|
||||
route.GET("/download/:size", download)
|
||||
authorized.GET("/download/:size", download)
|
||||
|
||||
route.GET("/search/*query", rutorSearch)
|
||||
authorized.GET("/search/*query", rutorSearch)
|
||||
|
||||
route.GET("/ffp/:hash/:id", ffp)
|
||||
authorized.GET("/ffp/:hash/:id", ffp)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user