middleware

package
v0.0.0-...-7bd706c Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AlgoHS256 is 256 bit encryption
	AlgoHS256 = "HS256"

	// AlgoHS512 is 512 bit encryption
	AlgoHS512 = "HS512"

	// AlgoHS1024 is 1024 bit encryptions
	AlgoHS1024 = "HS1024"
)

Variables

View Source
var DefaultCORSConfig = CORSConfig{
	AllowedOrigins: []string{"*"},
	AllowedMethods: []string{"GET", "POST", "PATCH", "PUT", "DELETE", "OPTIONS"},
	AllowedHeaders: []string{"*"},
	ExposedHeaders: []string{"*"},
}

DefaultCORSConfig handles the default CORS configuration for Huksy

View Source
var DefaultJWT = JWTConfig{
	SigningKey:    "secret",
	SigningMethod: AlgoHS256,
}

DefaultJWT is the default settings for the JWT

Functions

func CORS

func CORS(config CORSConfig) func(next husky.Handler) husky.Handler

CORS middleware for Husky routes

func CORSConfigured

func CORSConfigured(config CORSConfig) func(next husky.Handler) husky.Handler

CORSConfigured returns a configured CORS middleware func CORSConfigured(ctx husky.Context, handler husky.Handler, config CORSConfig) husky.Handler {

func CORSError

func CORSError(ctx *husky.CTX) error

CORSError returns a Husky Handler when an error is occured

func JWT

func JWT() func(next husky.Handler) husky.Handler

JWT default json web token handler

func JWTError

func JWTError(c husky.CTX) error

JWTError returns a husky Handler when an error is occured

Types

type CORSConfig

type CORSConfig struct {
	AllowedOrigins []string `json:"allowed_origins"`
	AllowedMethods []string `json:"allowed_methods"`
	AllowedHeaders []string `json:"allowed_headers"`
	ExposedHeaders []string `json:"exposed_headers"`
}

CORSConfig configuration for CORS middleware

type JWTConfig

type JWTConfig struct {
	SigningKey    interface{}
	SigningMethod string // Defaults to HS256
	Claims        jwt.Claims
}

JWTConfig holds token information

type TokenParser

type TokenParser func(*husky.CTX) (string, error)

TokenParser parses out token

Jump to

Keyboard shortcuts

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