middleware

package
v0.0.0-...-a613a2c Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2018 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Aegis

Aegis - Create an aegis middleware instance

func CORS

CORS returns a CORS middleware with sane defaults

CORS middleware can be invoked with a configuration using CORSWithConfig. This middleware will add CORS headers to all requests matched by the scope. This middleware must be used as Preroute middleware using the Scope.Pre function, instead of Scope.Use.

func CORSWithConfig

func CORSWithConfig(config CORSConfig) celerity.MiddlewareHandler

CORSWithConfig returns a CORS middleware handler with a specific configuration.

func JSONMiddleware

func JSONMiddleware() celerity.MiddlewareHandler

JSONMiddleware - Adds content type json headers

func RequestLogger

func RequestLogger() celerity.MiddlewareHandler

RequestLogger creates a new logger middleware with sane defaults.

func RequestLoggerWithConfig

func RequestLoggerWithConfig(rlc RequestLoggerConfig) celerity.MiddlewareHandler

RequestLoggerWithConfig creates a new Request logger with the given config.

func Rewrite

Rewrite returns a rewrite middleware with the given rewrite rules

Types

type AegisAdapter

type AegisAdapter interface {
	ValidateSession(c celerity.Context, token string) bool
}

AegisAdapter - Adapter interface for handling authentication

type AegisConfig

type AegisConfig struct {
	Adapter AegisAdapter
}

AegisConfig - Description

type CORSConfig

type CORSConfig struct {
	AllowOrigins     []string
	AllowMethods     []string
	AllowHeaders     []string
	AllowCredentials bool
	ExposeHeaders    []string
	Age              int
}

CORSConfig configures the cors middleware and can be passed to CORSWithConfig.

type RequestLoggerConfig

type RequestLoggerConfig struct {
	ConsoleTemplate string
	Log             *vox.Vox
}

RequestLoggerConfig configures the request logger middleware and can be passed to RequestLoggerWithConfig.

func NewLoggerConfig

func NewLoggerConfig() RequestLoggerConfig

NewLoggerConfig creates a default configuration for RequestLoggerConfig.

type RequestLoggerData

type RequestLoggerData struct {
	Now      time.Time
	URL      *url.URL
	Duration time.Duration
	C        *celerity.Context
	R        *celerity.Response
}

RequestLoggerData is used to format the output for console and file logging operations.

type RewriteRules

type RewriteRules map[string]string

RewriteRules is a set of rules used to rewrite and transform the incoming url. See the Server.Rewrite function.

func (RewriteRules) Match

func (rr RewriteRules) Match(path string) (bool, string)

Match check if a path matches any of the rules in the ruleset. If it does it returns the transformed URL.

Jump to

Keyboard shortcuts

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