middleware

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2020 License: BSD-2-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllowCORS

func AllowCORS() gin.HandlerFunc

func Authorize

func Authorize(cup CurrentUserProvider, isRequired ...bool) gin.HandlerFunc

func PanicLogger

func PanicLogger() gin.HandlerFunc

func Recover

func Recover(sc ServiceContext) gin.HandlerFunc

func RecoveryWithWriter

func RecoveryWithWriter(out io.Writer) gin.HandlerFunc

RecoveryWithWriter returns a middleware for a given writer that recovers from any panics and writes a 500 if there was one.

func RequireRoles

func RequireRoles(roles ...fmt.Stringer) gin.HandlerFunc

Types

type CurrentUserProvider

type CurrentUserProvider interface {
	GetCurrentUser(ctx context.Context, oauthID string) (sdkcm.User, error)
	ServiceContext
}

type ServiceContext

type ServiceContext interface {
	Logger(prefix string) logger.Logger
	Get(prefix string) (interface{}, bool)
	MustGet(prefix string) interface{}
}

Jump to

Keyboard shortcuts

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