Documentation ¶
Index ¶
- Constants
- Variables
- func Compress(level ...int) fiber.Handler
- func CompressWithConfig(config CompressConfig) fiber.Handler
- func Favicon(file ...string) fiber.Handler
- func Logger(format ...string) fiber.Handler
- func LoggerWithConfig(config LoggerConfig) fiber.Handler
- func Recover() fiber.Handler
- func RequestID(header ...string) fiber.Handler
- func RequestIDWithConfig(config RequestIDConfig) fiber.Handler
- func Timeout(handler fiber.Handler, timeout time.Duration) fiber.Handler
- type CompressConfig
- type LoggerConfig
- type RequestIDConfig
Constants ¶
const ( CompressLevelDisabled = -1 CompressLevelDefault = 0 CompressLevelBestSpeed = 1 CompressLevelBestCompression = 2 )
Compression levels
const ( LoggerTagTime = "time" LoggerTagReferer = "referer" LoggerTagProtocol = "protocol" LoggerTagIP = "ip" LoggerTagIPs = "ips" LoggerTagHost = "host" LoggerTagMethod = "method" LoggerTagPath = "path" LoggerTagURL = "url" LoggerTagUA = "ua" LoggerTagLatency = "latency" LoggerTagStatus = "status" LoggerTagBody = "body" LoggerTagBytesSent = "bytesSent" LoggerTagBytesReceived = "bytesReceived" LoggerTagRoute = "route" LoggerTagError = "error" LoggerTagHeader = "header:" LoggerTagQuery = "query:" LoggerTagForm = "form:" LoggerTagCookie = "cookie:" )
Logger variables
Variables ¶
var CompressConfigDefault = CompressConfig{ Next: nil, Level: CompressLevelDefault, }
CompressConfigDefault is the default config
var LoggerConfigDefault = LoggerConfig{ Next: nil, Format: "${time} ${method} ${path} - ${ip} - ${status} - ${latency}\n", TimeFormat: "15:04:05", Output: os.Stderr, }
LoggerConfigDefault is the default config
var RequestIDConfigDefault = RequestIDConfig{ Next: nil, Header: fiber.HeaderXRequestID, Generator: func() string { return utils.UUID() }, }
RequestIDConfigDefault is the default config
Functions ¶
func Compress ¶ added in v1.11.0
Compress is the default initiator allowing to pass the compression level It supports brotli, gzip and deflate compression The same order is used to check against the Accept-Encoding header
func CompressWithConfig ¶ added in v1.11.0
func CompressWithConfig(config CompressConfig) fiber.Handler
CompressWithConfig allows you to pass an CompressConfig It supports brotli, gzip and deflate compression The same order is used to check against the Accept-Encoding header
func LoggerWithConfig ¶ added in v1.11.0
func LoggerWithConfig(config LoggerConfig) fiber.Handler
LoggerWithConfig allows you to pass an CompressConfig
func RequestIDWithConfig ¶ added in v1.11.0
func RequestIDWithConfig(config RequestIDConfig) fiber.Handler
RequestIDWithConfig allows you to pass a custom config
Types ¶
type CompressConfig ¶ added in v1.11.0
type CompressConfig struct { // Next defines a function to skip this middleware. Next func(ctx *fiber.Ctx) bool // Compression level for brotli, gzip and deflate Level int }
CompressConfig defines the config for Compress middleware.
type LoggerConfig ¶ added in v1.8.1
type LoggerConfig struct { // Next defines a function to skip this middleware. Next func(ctx *fiber.Ctx) bool // Format defines the logging tags // // - time // - ip // - ips // - url // - host // - method // - path // - protocol // - route // - referer // - ua // - latency // - status // - body // - error // - bytesSent // - bytesReceived // - header:<key> // - query:<key> // - form:<key> // - cookie:<key> // // Optional. Default: ${time} ${method} ${path} - ${ip} - ${status} - ${latency}\n Format string // TimeFormat https://programming.guide/go/format-parse-string-time-date-example.html // // Optional. Default: 15:04:05 TimeFormat string // Output is a writter where logs are written // // Default: os.Stderr Output io.Writer }
LoggerConfig defines the config for Logger middleware.
type RequestIDConfig ¶ added in v1.8.1
type RequestIDConfig struct { // Next defines a function to skip this middleware. Next func(ctx *fiber.Ctx) bool // Header is the header key where to get/set the unique ID // Optional. Default: X-Request-ID Header string // Generator defines a function to generate the unique identifier. // Optional. Default: func() string { // return utils.UUID() // } Generator func() string }
RequestIDConfig defines the config for Logger middleware.