Documentation ¶
Index ¶
Constants ¶
View Source
const UsernameKey = "username"
UsernameKey defines the key in gin context which represents the owner of the secret.
View Source
const XRequestIDKey = "X-Request-ID"
XRequestIDKey defines X-Request-ID key string.
Variables ¶
View Source
var Middlewares = map[string]gin.HandlerFunc{ "recovery": gin.Recovery(), "secure": Secure, "options": Options, "nocache": NoCache, "cors": Cors(), "requestid": RequestID(), }
Middlewares store default middlewares.
Functions ¶
func NoCache ¶
NoCache is a middleware function that appends headers to prevent the client from caching the HTTP response.
func RequestID ¶
func RequestID() gin.HandlerFunc
RequestID returns a middleware that injects a 'X-Request-ID' into the context and request/response header of each request.
Types ¶
type AuthOperator ¶
type AuthOperator struct {
// contains filtered or unexported fields
}
AuthOperator is used to switch between different auth strategy.
func (*AuthOperator) AuthFunc ¶
func (operator *AuthOperator) AuthFunc() gin.HandlerFunc
AuthFunc executes authentication.
func (*AuthOperator) SetStrategy ¶
func (operator *AuthOperator) SetStrategy(strategy AuthStrategy)
SetStrategy sets the strategy to operator.
type AuthStrategy ¶
type AuthStrategy interface {
AuthFunc() gin.HandlerFunc
}
AuthStrategy is used to do authentication.
Click to show internal directories.
Click to hide internal directories.