Documentation ¶
Overview ¶
Package middleware implements common middlewares for http handlers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // AuthHeaderKey is the key for authorization header. AuthHeaderKey = "authorization" // AuthTypeBearer is the type of athorization token. AuthTypeBearer = "bearer" // AuthPayloadKey is the key for authorization payload. AuthPayloadKey = "authorization_payload" // ErrAuthHeaderNotFound indicates that an authorization header is not found. ErrAuthHeaderNotFound = errors.New("authorization header is not found") // ErrBadAuthHeaderFormat indicates invalid authorization header format. ErrBadAuthHeaderFormat = errors.New("invalid authorization header format") // ErrUnsupportedAuthType indicates unsupported authorization type. ErrUnsupportedAuthType = errors.New("unsupported authorization type") )
Functions ¶
func AddAuthorization ¶
func AddAuthorization(r *http.Request, tm tokenpkg.Maker, authType string, username string, d time.Duration) error
AddAuthorization sets authorization token to the given request.
func AuthMiddleware ¶
func AuthMiddleware(tokenMaker tokenpkg.Maker) gin.HandlerFunc
AuthMiddleware verifies request authorization token.
func CreateLogger ¶
CreateLogger returns logger depending on config environement.
func RequestLogger ¶
func RequestLogger(logger zerolog.Logger) gin.HandlerFunc
RequestLogger logs a gin HTTP request in JSON format.
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.