middleware

package
v0.1.15 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2021 License: MIT Imports: 14 Imported by: 19

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultCORSConfig = CORSConfig{
	AllowOrigins: []string{"*"},
	AllowMethods: []string{http.MethodGet, http.MethodHead, http.MethodPut, http.MethodPatch, http.MethodPost, http.MethodDelete},
}
View Source
var DefaultLoggerConfig = LoggerConfig{}
View Source
var DefaultRecoverConfig = RecoverConfig{
	DisablePrintStack: false,
}
View Source
var DefaultRequestIDConfig = RequestIDConfig{}
View Source
var DefaultTelemetryConfig = TelemetryConfig{
	ServiceName: "service",
}

Functions

func Compose

func Compose(l *zap.Logger, handler http.Handler, middlewares ...Middleware) http.Handler

func DefaultRequestIDGenerator

func DefaultRequestIDGenerator() string

Types

type CORSConfig

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

type LoggerConfig

type LoggerConfig struct{}

type Middleware

type Middleware func(*zap.Logger, http.Handler) http.Handler

Middleware your way to handle requests

func BasicAuth

func BasicAuth(user, password string) Middleware

func BearerAuth

func BearerAuth(bearerToken string) Middleware

func CORS

func CORS() Middleware

CORS returns a http middleware with default configuration

func CORSWithConfig

func CORSWithConfig(config CORSConfig) Middleware

CORSWithConfig returns a http middleware

func Logger

func Logger() Middleware

func LoggerWithConfig

func LoggerWithConfig(config LoggerConfig) Middleware

func Recover

func Recover() Middleware

func RecoverWithConfig

func RecoverWithConfig(config RecoverConfig) Middleware

func RequestID

func RequestID() Middleware

func RequestIDWithConfig

func RequestIDWithConfig(config RequestIDConfig) Middleware

func Telemetry

func Telemetry() Middleware

func TelemetryWithConfig

func TelemetryWithConfig(config TelemetryConfig) Middleware

type RecoverConfig

type RecoverConfig struct {
	DisablePrintStack bool
}

type RequestIDConfig

type RequestIDConfig struct {
	Generator func() string
}

type TelemetryConfig

type TelemetryConfig struct {
	ServiceName string
}

Jump to

Keyboard shortcuts

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