go get -u && gofumpt -w

This commit is contained in:
nikk gitanes
2024-02-26 18:35:19 +03:00
parent e1a2aa7324
commit 45e4ec054a
12 changed files with 384 additions and 382 deletions

View File

@@ -45,6 +45,6 @@ func SetupRoute(route gin.IRouter) {
} else {
authorized.GET("/search/*query", rutorSearch)
}
authorized.GET("/ffp/:hash/:id", ffp)
}

View File

@@ -20,7 +20,7 @@ func SetupAuth(engine *gin.Engine) {
}
accs := getAccounts()
if accs == nil {
return
return
}
engine.Use(BasicAuth(accs))
}
@@ -58,11 +58,11 @@ func (a authPairs) searchCredential(authValue string) (string, bool) {
func BasicAuth(accounts gin.Accounts) gin.HandlerFunc {
pairs := processAccounts(accounts)
return func(c *gin.Context) {
return func(c *gin.Context) {
c.Set("auth_required", true)
user, found := pairs.searchCredential(c.Request.Header.Get("Authorization"))
if found {
if found {
c.Set(gin.AuthUserKey, user)
}
}
@@ -77,7 +77,7 @@ func CheckAuth() gin.HandlerFunc {
if _, ok := c.Get(gin.AuthUserKey); ok {
return
}
c.Header("WWW-Authenticate", "Basic realm=Authorization Required")
c.AbortWithStatus(http.StatusUnauthorized)
}

View File

@@ -33,7 +33,7 @@ func asset(c *gin.Context, t string, d []byte) {
func SetupRoute(r gin.IRouter) {
authorized := r.Group("/", auth.CheckAuth())
authorized.GET("/msx/:pth", msxPTH)
authorized.GET("/msx/imdb", msxIMDB)
authorized.GET("/msx/imdb/:id", msxIMDBID)