Documentation
¶
Index ¶
- func LogWebRequest(c fiber.Ctx, startTime *time.Time, elapsedTime *time.Duration, ...)
- func NewAccessLogger(logger *zap.Logger, disableSSRLogs bool, useColor bool) fiber.Handler
- func NewCachedETag(config CachedETagConfig) fiber.Handler
- type CachedETagConfig
- type CachedETagResolver
- type CachedETagResource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LogWebRequest ¶
func NewAccessLogger ¶
NewAccessLogger returns a middleware that logs requests and responses using the provided logger.
Pass disableSSRLogs=true to skip logging for SSR requests (useful in development)
func NewCachedETag ¶
func NewCachedETag(config CachedETagConfig) fiber.Handler
NewCachedETag returns a middleware that reuses previously observed ETags and can short-circuit with 304 Not Modified before downstream response generation.
This middleware is intended to sit in front of Fiber's standard etag middleware, not replace it. On a cache miss it calls the next handler, captures the emitted ETag and related cache headers, and stores them in an in-memory cache scoped to this middleware instance. On a hit it compares the request's If-None-Match header against the cached ETag and returns 304 before downstream handlers run.
The cache is keyed by CachedETagResource.Key and guarded by CachedETagResource.Version. If the version changes, the cached validator is treated as stale and the downstream chain is allowed to regenerate the response and its ETag.
Types ¶
type CachedETagConfig ¶
type CachedETagConfig struct {
// Next skips the middleware when it returns true.
Next func(c fiber.Ctx) bool
// Resolve identifies the cacheable resource for the current request.
Resolve CachedETagResolver
}
CachedETagConfig configures NewCachedETag.
type CachedETagResolver ¶
type CachedETagResolver func(c fiber.Ctx) (CachedETagResource, bool)
CachedETagResolver resolves the logical resource behind the current request.
Returning ok=false skips this middleware for the request.
type CachedETagResource ¶
CachedETagResource identifies a cacheable downstream response.
Key must be stable for the logical resource across requests, while Version must change whenever that resource's body would produce a different ETag. Together they let the middleware reuse a previously emitted validator without keying the cache directly by request URL.