package middleware import ( "basic-sensor-receiver/app" "net/http" "github.com/gin-gonic/gin" ) func LoginAuthMiddleware(server *app.Server) gin.HandlerFunc { return func(c *gin.Context) { _, err := server.Services.Auth.FromContext(c) if err != nil { c.AbortWithError(http.StatusUnauthorized, err) return } c.Next() } } func KeyAuthMiddleware(server *app.Server) gin.HandlerFunc { return func(c *gin.Context) { if c.GetHeader("authorization") != server.Config.AuthKey { c.AbortWithStatus(http.StatusUnauthorized) return } c.Next() } }