View Source Maverick.Path (Maverick v0.3.0)

Provides functionality for parsing paths to lists of path nodes, identifying path variables for pattern matching on incoming requests.

Link to this section Summary

Functions

Parse a path string to a list of path nodes. A path node is either a String.t() or a tuple of {:variable, String.t()}. Nodes beginning with a colon character (":") will parse to a variable tuple. At runtime, variable tuples are used to construct the path params portion of a Maverick request.

Reads a path string and validates as a Maverick-compatible path, including any colon (":") characters signifying a path variable. Strips any extraneous forward slashes from the result.

Link to this section Types

@type path() :: [path_node()]
@type path_node() :: String.t() | {:variable, String.t()}
@type raw_path() :: String.t()

Link to this section Functions

@spec parse(String.t()) :: path()

Parse a path string to a list of path nodes. A path node is either a String.t() or a tuple of {:variable, String.t()}. Nodes beginning with a colon character (":") will parse to a variable tuple. At runtime, variable tuples are used to construct the path params portion of a Maverick request.

@spec validate(String.t()) :: raw_path()

Reads a path string and validates as a Maverick-compatible path, including any colon (":") characters signifying a path variable. Strips any extraneous forward slashes from the result.