18 lines
315 B
Go
18 lines
315 B
Go
|
package auth
|
||
|
|
||
|
import (
|
||
|
"net/http"
|
||
|
|
||
|
"github.com/gin-gonic/gin"
|
||
|
)
|
||
|
|
||
|
func AuthMiddleware() gin.HandlerFunc {
|
||
|
return func(ctx *gin.Context) {
|
||
|
if ctx.Request.Header["Static-Hoster-Key"][0] != "007" {
|
||
|
ctx.AbortWithStatusJSON(http.StatusUnauthorized, gin.H{"error": "Unauthorized"})
|
||
|
return
|
||
|
}
|
||
|
ctx.Next()
|
||
|
}
|
||
|
}
|