Documentation
¶
Overview ¶
Package pipe reads one value out of a request and converts it, returning an error that already carries the right status and the right field name.
It exists because the alternative — `uuid.Parse(c.Params("id"))` with a hand-written error beside it — is written slightly differently at every call site, and some of those forget the error entirely and pass a zero UUID into a query.
Index ¶
- func BoolQuery(c fiber.Ctx, name string, def bool) (bool, error)
- func CSVQuery(c fiber.Ctx, name string) []string
- func EnumQuery(c fiber.Ctx, name string, allowed ...string) (string, error)
- func IntParam(c fiber.Ctx, name string) (int, error)
- func IntQuery(c fiber.Ctx, name string, def int) (int, error)
- func StringParam(c fiber.Ctx, name string) (string, error)
- func TimeQuery(c fiber.Ctx, name string) (time.Time, error)
- func UUIDParam(c fiber.Ctx, name string) (uuid.UUID, error)
- func UUIDQuery(c fiber.Ctx, name string) (uuid.UUID, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BoolQuery ¶
BoolQuery reads an optional query parameter as a bool, falling back to def. It accepts the forms a browser and a CLI actually send: true/false, 1/0, yes/no, on/off.
func EnumQuery ¶
EnumQuery reads an optional query parameter constrained to a fixed set. An empty value returns "" and no error, so the caller decides the default.
func StringParam ¶
StringParam reads a required, trimmed path parameter.
Types ¶
This section is empty.