Documentation
¶
Overview ¶
🚀 Fiber is an Express inspired web framework written in Go with 💖 📌 API Documentation: https://fiber.wiki 📝 Github Repository: https://github.com/gofiber/fiber Special thanks to Echo: https://github.com/labstack/echo/blob/master/middleware/key_auth.go
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // When there is no request of the key thrown ErrMissingOrMalformedAPIKey ErrMissingOrMalformedAPIKey = errors.New("missing or malformed API Key") )
Functions ¶
Types ¶
type Config ¶
type Config struct {
// Filter defines a function to skip middleware.
// Optional. Default: nil
Filter func(*fiber.Ctx) bool
// SuccessHandler defines a function which is executed for a valid key.
// Optional. Default: nil
SuccessHandler fiber.Handler
// ErrorHandler defines a function which is executed for an invalid key.
// It may be used to define a custom error.
// Optional. Default: 401 Invalid or expired key
ErrorHandler fiber.ErrorHandler
// KeyLookup is a string in the form of "<source>:<name>" that is used
// to extract key from the request.
// Optional. Default value "header:Authorization".
// Possible values:
// - "header:<name>"
// - "query:<name>"
// - "form:<name>"
// - "param:<name>"
// - "cookie:<name>"
KeyLookup string
// AuthScheme to be used in the Authorization header.
// Optional. Default value "Bearer".
AuthScheme string
// Validator is a function to validate key.
// Optional. Default: nil
Validator func(*fiber.Ctx, string) (bool, error)
// Context key to store the bearertoken from the token into context.
// Optional. Default: "token".
ContextKey string
}
Click to show internal directories.
Click to hide internal directories.