Documentation
¶
Index ¶
- Constants
- Variables
- func ParseCSVQuery(c *fiber.Ctx, name string) []string
- 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 ParseListingPage(c *fiber.Ctx) (listing.Page, error)
- func ParseOptionalBool(c *fiber.Ctx, name string) (*bool, error)
- func ParsePage(c *fiber.Ctx) (int, error)
- func ParseSearch(c *fiber.Ctx) string
- func ParseSize(c *fiber.Ctx) (int, error)
- func ParseSort(c *fiber.Ctx, allowed []string) (listing.Sort, 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 ErrInvalidFilter = errors.New("invalid filter parameter")
var ErrInvalidPage = errors.New("invalid page parameter")
var ErrInvalidSize = errors.New("invalid size parameter")
var ErrInvalidSort = errors.New("invalid sort 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 ParseListingPage ¶ added in v0.34.0
ParseListingPage parses page and size into a listing.Page.
func ParseOptionalBool ¶ added in v0.34.0
ParseOptionalBool parses an optional boolean query param. Missing returns nil.
func ParseSearch ¶ added in v0.34.0
ParseSearch returns the search query. `search` takes precedence; `name` is kept as a backwards-compatible alias.
func ParseSort ¶ added in v0.34.0
ParseSort validates sort/order against an allowed field whitelist. An empty sort returns a zero listing.Sort (repository default). Order without sort, unknown fields, and unknown directions are rejected.
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.