pipe

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 7, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolQuery

func BoolQuery(c fiber.Ctx, name string, def bool) (bool, error)

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 CSVQuery

func CSVQuery(c fiber.Ctx, name string) []string

CSVQuery reads an optional comma-separated list, trimmed, with empties dropped.

func EnumQuery

func EnumQuery(c fiber.Ctx, name string, allowed ...string) (string, error)

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 IntParam

func IntParam(c fiber.Ctx, name string) (int, error)

IntParam reads a path parameter as an int.

func IntQuery

func IntQuery(c fiber.Ctx, name string, def int) (int, error)

IntQuery reads an optional query parameter as an int, falling back to def.

func StringParam

func StringParam(c fiber.Ctx, name string) (string, error)

StringParam reads a required, trimmed path parameter.

func TimeQuery

func TimeQuery(c fiber.Ctx, name string) (time.Time, error)

TimeQuery reads an optional RFC 3339 timestamp.

func UUIDParam

func UUIDParam(c fiber.Ctx, name string) (uuid.UUID, error)

UUIDParam reads a path parameter as a UUID.

func UUIDQuery

func UUIDQuery(c fiber.Ctx, name string) (uuid.UUID, error)

UUIDQuery reads an OPTIONAL query parameter as a UUID. A missing value returns uuid.Nil and no error; a present but malformed one is an error.

The distinction matters: `?category_id=` meaning "every category" and `?category_id=oops` meaning "a typo" must not behave the same way.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL