Documentation ¶
Overview ¶
Package middleware provides middleware, such as logging, recovery, authentication etc.
Index ¶
- func Authenticated(db *mongo.Database, jwtSettings model.JwtSettings, scopes []string) gin.HandlerFunc
- func LoggingMiddleware() gin.HandlerFunc
- func RecoveryMiddleware() gin.HandlerFunc
- func RecoveryWithWriter(out io.Writer, simple bool, response interface{}) gin.HandlerFunc
- type AuthenticationMiddleware
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Authenticated ¶
func Authenticated(db *mongo.Database, jwtSettings model.JwtSettings, scopes []string) gin.HandlerFunc
Authenticated is an authentication middleware. It checks Authorization header for JWT access token, that verifies and tries to find that token in the database. If token is bad, 401 HTTP code and JSON error is returned. If token has not all necessary scopes, 403 HTTP code and JSON error is returned.
func LoggingMiddleware ¶
func LoggingMiddleware() gin.HandlerFunc
LoggingMiddleware simply logs all incoming requests.
func RecoveryMiddleware ¶
func RecoveryMiddleware() gin.HandlerFunc
RecoveryMiddleware returns a middleware that recovers from any panics and writes a 500 if there was one.
func RecoveryWithWriter ¶
func RecoveryWithWriter(out io.Writer, simple bool, response interface{}) gin.HandlerFunc
RecoveryWithWriter returns a middleware for a given writer that recovers from any panics and writes a 500 if there was one.
Types ¶
type AuthenticationMiddleware ¶
type AuthenticationMiddleware struct {
// contains filtered or unexported fields
}
AuthenticationMiddleware struct contains all necessary data for determining is user can see a resource.