handlers

package
v0.0.0-...-6899a91 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2019 License: BSD-3-Clause Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyRoles    = "roles"
	KeyLogEntry = "logger"
)

Gin context keys

Variables

This section is empty.

Functions

func AuthMiddleware

func AuthMiddleware(policy security.Policy) gin.HandlerFunc

AuthMiddleware returns a middleware that populate the Gin Context with security data

func BindHook

func BindHook(c *gin.Context, i interface{}) error

BindHook hook for lhasa, override default one

func GetLogger

func GetLogger(c *gin.Context) *logrus.Entry

GetLogger returns the request logger from the gin context, nil if it does not exist

func HasOne

func HasOne(roles ...security.Role) gin.HandlerFunc

HasOne returns a gin handler that checks the request against the given role

func LoggingMiddleware

func LoggingMiddleware(logHeaders []string, log logrus.FieldLogger) gin.HandlerFunc

LoggingMiddleware logs before and after incoming gin requests

func PingHandler

func PingHandler(db *sql.DB) func(c *gin.Context) (string, error)

PingHandler provides monitoring status on a rest endpoint

func RecoveryWithLogger

func RecoveryWithLogger(log logrus.FieldLogger) gin.HandlerFunc

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

func RenderHookWrapper

func RenderHookWrapper(hook tonic.RenderHook) tonic.RenderHook

RenderHookWrapper hook for lhasa, override default one

func VersionHandler

func VersionHandler(version string) func(*gin.Context) (string, error)

VersionHandler displays the current version number

Types

type MediaResource

type MediaResource interface {
	GetContentType() string
	GetBytes() []byte
	SetBytes([]byte)
}

MediaResource defines a media resource behaviour

Jump to

Keyboard shortcuts

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