middleware

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2019 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultCORSConfig is the default CORS middleware config.
	DefaultCORSConfig = CORSConfig{
		Skipper:       DefaultSkipper,
		AllowOrigins:  []string{"*"},
		AllowMethods:  []string{raptor.HEAD, raptor.GET, raptor.POST, raptor.PUT, raptor.PATCH, raptor.DELETE},
		AllowHeaders:  []string{raptor.HeaderOrigin, raptor.HeaderAccept, raptor.HeaderContentType, raptor.HeaderAuthorization, raptor.HeaderContentLength, raptor.HeaderAcceptCharset, "X-Requested-With"},
		ExposeHeaders: []string{raptor.HeaderContentDisposition},
	}
)
View Source
var (
	// DefaultCSRFConfig :
	DefaultCSRFConfig = CSRFConfig{
		Skipper: DefaultSkipper,
	}
)
View Source
var (
	DefaultSecureConfig = SecureConfig{
		Skipper:            DefaultSkipper,
		XSSProtection:      "1; mode=block",
		ContentTypeNosniff: "nosniff",
		XFrameOptions:      "SAMEORIGIN",
	}
)

DefaultSecureConfig :

Functions

func CORS

func CORS(config ...CORSConfig) raptor.MiddlewareFunc

CORS :

func CSRF

func CSRF(config ...CSRFConfig) raptor.MiddlewareFunc

CSRF :

func DefaultSkipper

func DefaultSkipper(*raptor.Context) bool

DefaultSkipper :

func Recover

func Recover(config ...SecureConfig) raptor.MiddlewareFunc

Recover :

func Secure

func Secure(config ...SecureConfig) raptor.MiddlewareFunc

Secure :

Types

type CORSConfig

type CORSConfig struct {
	Skipper          Skipper
	AllowOrigins     []string `yaml:"allow_origins"`
	AllowMethods     []string `yaml:"allow_methods"`
	AllowHeaders     []string `yaml:"allow_headers"`
	AllowCredentials bool     `yaml:"allow_credentials"`
	ExposeHeaders    []string `yaml:"expose_headers"`
	MaxAge           int      `yaml:"max_age"`
}

CORSConfig :

type CSRFConfig

type CSRFConfig struct {
	Skipper     Skipper
	TokenLength uint8  `yaml:"token_length"`
	TokenLookup string `yaml:"token_lookup"`
	ContextKey  string `yaml:"context_key"`
	Cookie      *fasthttp.Cookie
}

CSRFConfig :

type RecoverConfig

type RecoverConfig struct {
	Skipper Skipper
}

RecoverConfig :

type SecureConfig

type SecureConfig struct {
	Skipper               Skipper
	XSSProtection         string `yaml:"xss_protection"`
	ContentTypeNosniff    string `yaml:"content_type_nosniff"`
	XFrameOptions         string `yaml:"x_frame_options"`
	HSTSMaxAge            int    `yaml:"hsts_max_age"`
	HSTSExcludeSubdomains bool   `yaml:"hsts_exclude_subdomains"`
	ContentSecurityPolicy string `yaml:"content_security_policy"`
}

SecureConfig :

type Skipper

type Skipper func(*raptor.Context) bool

Skipper defines a function to skip middleware. Returning true skips processing the middleware.

Jump to

Keyboard shortcuts

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