Documentation ¶
Index ¶
Constants ¶
const RequestIDKey string = "requestid"
RequestIDKey is the fiber context key for the request ID.
Variables ¶
var ErrMissingRequestID = errors.New("no request ID set on request context")
ErrMissingRequestID is returned when a request ID is not present in the context.
Functions ¶
func CORS ¶
func CORS(allowOrigins string) fiber.Handler
CORS returns a middleware that handles OPTIONS requests and sets the CORS headers on the response.
func RequestIDFrom ¶
RequestIDFrom returns the request ID from the Fiber context, or ErrMissingRequestID if no request ID is present.
func RequestIDInjection ¶
func RequestIDInjection() fiber.Handler
RequestIDInjection returns middleware injects a UUID into the context of each request.
func RequestScopedLoggerInjection ¶
func RequestScopedLoggerInjection(logger Logger) fiber.Handler
RequestScopedLoggerInjection is Fiber middleware that adds a request-scoped logger containing the current request ID to the Fiber context.
func RequestStatsLogging ¶
RequestStatsLogging wraps the standard Fiber logger middleware, specifying a log format that can be reused consistently across the application (e.g. between the application server and test servers).
Types ¶
type Logger ¶
type Logger interface {
Printf(format string, v ...interface{})
}
Logger represents the minimal set of methods required to log messages.
func LoggerFrom ¶
func LoggerFrom(c *fiber.Ctx) Logger
LoggerFrom returns the request-scoped logger from the Fiber context, or [noOpLogger] if no logger is present.
type MockLogger ¶
type MockLogger struct {
Buf io.ReadWriter
}
func (*MockLogger) Printf ¶
func (m *MockLogger) Printf(format string, v ...interface{})