cowboy_constraints(3)

NAME

cowboy_constraints - Constraints

DESCRIPTION

The module cowboy_constraints defines the built-in constraints in Cowboy and provides an interface for manipulating these constraints.

Constraints are functions that define what type of input is allowed. They are used throughout Cowboy, from the router to query strings to cookies.

EXPORTS

Built-in constraints:

    • cowboy_constraints:int(3) - Integer constraint
    • cowboy_constraints:nonempty(3) - Non-empty constraint

Constraint generators:

    • cowboy_constraints:from_fun(3) - Create a constraint from a 1-arity function

TYPES

  constraint()
    constraint() :: int | nonempty | fun()

A constraint function.

The atom constraints are built-in, see the corresponding function in the exports list above.

  reason()
    reason() :: {constraint(), Reason, Value}

    Reason :: any()
    Value  :: any()

Reason for the constraint failure.

It includes the constraint function in question, a machine-readable error reason and the value that made the constraint fail.

SEE ALSO

cowboy(7), cowboy(3), cowboy_router(3), cowboy_req:match_cookies(3), cowboy_req:match_qs(3)