middleware

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const SEP = ", "

Variables

This section is empty.

Functions

func AttachGzipCompress

func AttachGzipCompress(ginEngine *gin.Engine) *gin.Engine

func CORS

func CORS() gin.HandlerFunc

CORS (Cross-Origin Resource Sharing)

func DisableCache

func DisableCache() gin.HandlerFunc

DisableCache is a middleware function that appends headers to prevent the client from caching the HTTP response.

func Metrics added in v0.1.4

func Metrics() gin.HandlerFunc

Metrics is a middleware function that enables metrics

func Recover

func Recover() gin.HandlerFunc

func RequestID

func RequestID(key string) gin.HandlerFunc

func Secure

func Secure() gin.HandlerFunc

Secure is a middleware function that appends security and resource access headers

func TokenAuthMiddleware added in v0.1.5

func TokenAuthMiddleware(ignorePaths []string, secret []byte) gin.HandlerFunc

TokenAuthMiddleware is a middleware function that checks for a valid token in the Authorization header

Types

type Middleware

type Middleware struct {
	// contains filtered or unexported fields
}

func AttachTo

func AttachTo(ginEngine *gin.Engine) *Middleware

func (*Middleware) WithAuth added in v0.1.5

func (m *Middleware) WithAuth(ignorePaths []string, secret []byte) *Middleware

WithAuth is a middleware function that checks for a valid token in the Authorization header ignorePaths: paths that do not need to check token,prefix match

func (*Middleware) WithCORS

func (m *Middleware) WithCORS() *Middleware

WithCORS is a middleware function that allow CORS

func (*Middleware) WithCacheDisabled

func (m *Middleware) WithCacheDisabled() *Middleware

WithCacheDisabled is a middleware function that sets cache headers

func (*Middleware) WithCompress

func (m *Middleware) WithCompress() *Middleware

WithCompress is a middleware function that compresses the response

func (*Middleware) WithMetrics added in v0.1.4

func (m *Middleware) WithMetrics() *Middleware

WithMetrics is a middleware function that enables metrics

func (*Middleware) WithRecover

func (m *Middleware) WithRecover() *Middleware

WithRecover is a middleware function that recovers from any panics and writes a 500 if there was one

func (*Middleware) WithRequestID

func (m *Middleware) WithRequestID(key string) *Middleware

WithRequestID is a middleware function that sets a request ID

func (*Middleware) WithSecurity

func (m *Middleware) WithSecurity() *Middleware

WithSecurity is a middleware function that enhance security

Jump to

Keyboard shortcuts

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