middleware

package
v0.0.0-...-6ce5408 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2021 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	SignCode      = "X-Sign"
	SignTimestamp = "X-Sign-Timestamp"
	SignAppid     = "X-App-Id"
)

Variables

View Source
var DefaultMiddlewares = Middlewares{
	Handles: []Middleware{&Logger{}, &Recovery{}},
}

Functions

func NewSign

func NewSign(uri, body, timestamp, appSecret string) string

func PrometheusHandler

func PrometheusHandler() fasthttp.RequestHandler

since prometheus/client_golang use net/http we need this net/http adapter for fasthttp

func VerifySign

func VerifySign(uri, body, timestamp, appSecret, sig string, duration int64) bool

Types

type Authorization

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

func NewAuthorization

func NewAuthorization(appid, secret string, duration int64) *Authorization

func (*Authorization) Handle

func (*Authorization) Verify

func (a *Authorization) Verify(ctx *fasthttp.RequestCtx) bool

type CorsHandler

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

func DefaultCorsHandler

func DefaultCorsHandler() *CorsHandler

func NewCorsHandler

func NewCorsHandler(options Options) *CorsHandler

func (*CorsHandler) Handle

type Logger

type Logger struct {
}

func NewLogger

func NewLogger() *Logger

func (*Logger) Handle

func (l *Logger) Handle() func(next fasthttp.RequestHandler) fasthttp.RequestHandler

type Middleware

type Middleware interface {
	Handle() func(next fasthttp.RequestHandler) fasthttp.RequestHandler
}

type Middlewares

type Middlewares struct {
	Handles []Middleware
}

func NewMiddlewares

func NewMiddlewares(middlewares ...Middleware) Middlewares

NewMiddlewares returns middlewares

func (Middlewares) Append

func (m Middlewares) Append(middlewares ...Middleware) Middlewares

Append copy all middleware layers to newLayers, then append middlewares to newLayers, then return a new middleware onion.

func (Middlewares) Apply

type Options

type Options struct {
	AllowedOrigins   []string
	AllowedHeaders   []string
	AllowMaxAge      int
	AllowedMethods   []string
	ExposedHeaders   []string
	AllowCredentials bool
	Debug            bool
}

Options is struct that defined cors properties

func NewOption

func NewOption(origins []string) *Options

type Prometheus

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

Prometheus contains the metrics gathered by the instance and its path

func NewPrometheus

func NewPrometheus(subsystem, uri string) *Prometheus

NewPrometheus generates a new set of metrics with a certain subsystem name

func (*Prometheus) Handle

func (p *Prometheus) Handle() func(next fasthttp.RequestHandler) fasthttp.RequestHandler

type Recovery

type Recovery struct {
}

func NewRecovery

func NewRecovery() *Recovery

func (*Recovery) Handle

func (r *Recovery) Handle() func(next fasthttp.RequestHandler) fasthttp.RequestHandler

Jump to

Keyboard shortcuts

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