Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetCacheControlMiddleware ¶
SetCacheControlMiddleware sets the Cache-Control header for a route or group in Fiber.
Parameters:
cacheType: One of the allowed CacheType values (public, private, no-store, no-cache). ttl: Time to live in seconds for the cache (max-age). If <= 0, max-age is omitted.
Usage:
app.Get("/route", SetCacheControlMiddleware(CachePublic, 60), handler)
If an invalid cacheType is provided, the middleware returns an error and does not set the header.
Types ¶
type CacheType ¶
type CacheType string
CacheType defines allowed values for the Cache-Control header type. Use the provided constants for safety and validation.
type ForwardedHeadersKeyType ¶
type ForwardedHeadersKeyType struct{}
type Server ¶
func NewServer ¶
NewServer creates and configures a Fiber server instance.
Parameters:
name: The name of the origin application. Used for the X-Origin-App header. forwardHeaders: List of headers to be forwarded. If empty, uses defaults.
Behavior:
- Removes default server identification headers.
- Sets the X-Origin-App header in the request.
- Applies ForwardHeadersMiddleware to collect and forward headers.
- Adds a /healthcheck endpoint for health monitoring.
Usage:
server := NewServer("my-app", []string{"x-request-id", "x-client-user-agent"})
log.Fatal(server.App.Listen(":8080"))
Click to show internal directories.
Click to hide internal directories.