-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
enhancementNew feature or requestNew feature or request
Description
TODO:
- 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.
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Projects
Status
Todo