You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

18 lines
331 B

package middleware
import (
"context"
"github.com/gofiber/fiber/v2"
)
func BasicAuth() fiber.Handler {
return func(c *fiber.Ctx) error {
token := string(c.Request().Header.Peek("Authorization"))
if token != "" {
ctx := context.WithValue(c.Context(), "token", token)
c.SetUserContext(ctx)
}
return c.Next()
}
}