middleware

package
v0.0.0-...-f5986cb Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 21, 2020 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package middleware provides middleware, such as logging, recovery, authentication etc.

Index

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL