middleware

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2024 License: BSD-2-Clause Imports: 17 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, tracker Tracker, isRequired ...bool) gin.HandlerFunc

func AuthorizeWithCache

func AuthorizeWithCache(cup CurrentUserProvider, cache Caching, tracker Tracker, 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 Caching

type Caching interface {
	GetCurrentUser(ctx context.Context, sig string) (sdkcm.Requester, error)
	WriteCurrentUser(ctx context.Context, sig string, u sdkcm.Requester) error
}

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{}
}

type Tracker

type Tracker interface {
	TrackApiCall(userId uint32, url string) error
}

Jump to

Keyboard shortcuts

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