You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enhance API Route & API Group to support multiple handlers
Note
It seems possible to Enhance API Route & API Group to support multiple handlers. For example, could use multiple RateLimiter instances in a single API Route or API Group. This is the current structure:
// APIRoute represents a single API route, containing the path, HTTP method,
// handler function, and an optional rate limiter.
type APIRoute struct {
Path string
Method string
Handler fiber.Handler
RateLimiter fiber.Handler
KeyAuth fiber.Handler
RequestID fiber.Handler
EncryptedCookieMiddleware fiber.Handler
}
// APIGroup represents a group of API routes under a common prefix.
// It also allows for a group-wide rate limiter.
type APIGroup struct {
Prefix string
Routes []APIRoute
RateLimiter fiber.Handler
KeyAuth fiber.Handler
RequestID fiber.Handler
EncryptedCookieMiddleware fiber.Handler
}
Example:
apiGroups := []APIGroup{
{ // Note: Example https://localhost:8080/v1/server/health/db
Prefix: "/server/health",
RateLimiter: rateLimiterRESTAPIs1, rateLimiterRESTAPIs2,etc // This is an optional example.
Routes: []APIRoute{
{
Path: "/db",
// Note: This approach allows defining multiple HTTP methods (e.g., GET, POST, PUT, DELETE) for a single handler & path.
Method: strings.Join([]string{
fiber.MethodGet,
}, ","),
Handler: health.DBHandler(db),
},
},
},
}
Also note that it is useful for cookies, because cookie values have limited length, especially for encrypting sensitive data.
The text was updated successfully, but these errors were encountered:
TODO:
Note
It seems possible to
Enhance API Route & API Group to support multiple handlers
. For example, could use multipleRateLimiter
instances in a single API Route or API Group. This is the current structure:Example:
Also note that it is useful for
cookies
, because cookie values have limited length, especially for encrypting sensitive data.The text was updated successfully, but these errors were encountered: