mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-20 05:56:10 +05:00
Refactor auth code
This commit is contained in:
@@ -6,13 +6,16 @@ import (
|
||||
|
||||
"server/settings"
|
||||
"server/torr"
|
||||
"server/web/auth"
|
||||
"server/web/pages/template"
|
||||
)
|
||||
|
||||
func SetupRoute(route *gin.RouterGroup) {
|
||||
template.RouteWebPages(route)
|
||||
route.GET("/stat", statPage)
|
||||
route.GET("/magnets", getTorrents)
|
||||
func SetupRoute(route gin.IRouter) {
|
||||
authorized := route.Group("/", auth.CheckAuth())
|
||||
|
||||
template.RouteWebPages(authorized)
|
||||
authorized.GET("/stat", statPage)
|
||||
authorized.GET("/magnets", getTorrents)
|
||||
}
|
||||
|
||||
// stat godoc
|
||||
|
||||
@@ -3,10 +3,11 @@ package template
|
||||
import (
|
||||
"crypto/md5"
|
||||
"fmt"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func RouteWebPages(route *gin.RouterGroup) {
|
||||
func RouteWebPages(route gin.IRouter) {
|
||||
route.GET("/", func(c *gin.Context) {
|
||||
etag := fmt.Sprintf("%x", md5.Sum(Indexhtml))
|
||||
c.Header("Cache-Control", "public, max-age=31536000")
|
||||
|
||||
Reference in New Issue
Block a user