Documentation
¶
Index ¶
- Constants
- Variables
- func ParseConsumerAssociationID[K ids.Kind](c *fiber.Ctx, targetParam string) (ids.GatewayID, ids.ConsumerID, ids.ID[K], error)
- func ParseGatewayID(c *fiber.Ctx) (ids.GatewayID, error)
- func ParseGatewayScopedID[K ids.Kind](c *fiber.Ctx) (ids.GatewayID, ids.ID[K], error)
- func ParsePage(c *fiber.Ctx) (int, error)
- func ParseSize(c *fiber.Ctx) (int, error)
- func ParseUUIDParam[K ids.Kind](c *fiber.Ctx, name string) (ids.ID[K], error)
- func WriteCreated(c *fiber.Ctx, body any) error
- func WriteError(c *fiber.Ctx, err error) error
- func WriteListEnvelope(c *fiber.Ctx, items any, page, size, total int) error
- func WriteNoContent(c *fiber.Ctx) error
- func WriteOK(c *fiber.Ctx, body any) error
- type ErrorBody
- type ListEnvelope
Constants ¶
const ( DefaultPage = 1 DefaultSize = 20 MaxSize = 200 )
Variables ¶
var ErrInvalidPage = errors.New("invalid page parameter")
var ErrInvalidSize = errors.New("invalid size parameter")
var ErrInvalidUUIDParam = errors.New("invalid uuid path parameter")
Functions ¶
func ParseGatewayID ¶
ParseGatewayID parses the required :gateway_id path param shared by every gateway-scoped collection handler (create/list).
func ParseGatewayScopedID ¶
ParseGatewayScopedID parses the required :gateway_id and :id path params shared by every gateway-scoped sub-resource handler (get/update/delete).
func WriteError ¶
WriteError is a convenience wrapper around MapDomainError + JSON write. Every error funnelled through here is logged at Error level with the caller site and a stack trace, so a failing endpoint always leaves a trace even when the wire response collapses to a generic code (e.g. 500 "internal_error").
func WriteListEnvelope ¶
func WriteNoContent ¶
Types ¶
type ErrorBody ¶
ErrorBody is the JSON shape emitted on every error response. Handlers MUST go through MapDomainError so the wire format stays consistent.
func MapDomainError ¶
MapDomainError translates an application/domain error into the matching HTTP status code and a stable error code string. Entity-specific sentinels add their cases here as their `<entity>-a` slices land.
Unknown errors collapse to 500 + "internal_error" — callers should have already logged the underlying error with the request context.