Liking cljdoc? Tell your friends :D

io.pedestal.http.route


decode-query-partclj

(decode-query-part string)

Decodes one key or value of URL-encoded UTF-8 characters in a URL query string.

Decodes one key or value of URL-encoded UTF-8 characters in a URL
query string.
sourceraw docstring

encode-query-partclj

(encode-query-part string)

Encodes one key or value for a UTF-8 URL-encoded query string. Encodes space as +.

Encodes one key or value for a UTF-8 URL-encoded query string.
Encodes space as +.
sourceraw docstring

expand-routesclj

(expand-routes route-spec)

Given a value (the route specification), produce and return a routing table, a seq of verbose routing maps.

A route specification is any type that satisfies ExpandableRoutes; this includes Clojure vectors, maps, and sets (for terse, table, and verbose routes).

Ensures the integrity of expanded routes (even if they've already been checked):

  • Constraints are correctly ordered (most specific to least specific)
  • Route names are unique
Given a value (the route specification), produce and return a routing table,
a seq of verbose routing maps.

A route specification is any type that satisfies [[ExpandableRoutes]];
this includes Clojure vectors, maps, and sets (for terse, table, and verbose routes).

Ensures the integrity of expanded routes (even if they've already been checked):

- Constraints are correctly ordered (most specific to least specific)
- Route names are unique
sourceraw docstring

ExpandableRoutescljprotocol

A protocol extended onto types that can be used to convert instances into a seq of verbose route maps, the routing table.

Built-in implementations map vectors to [[terse-routes]], sets to [[table-routes]], and maps to [[map-routes->vec-routes]].

A protocol extended onto types that can be used to convert instances into a seq of verbose route maps,
the routing table.

Built-in implementations map vectors to [[terse-routes]],
sets to [[table-routes]], and maps to [[map-routes->vec-routes]].

-expand-routesclj

(-expand-routes expandable-route-spec)

Generate and return the routing table from a given expandable form of routing data.

Generate and return the routing table from a given expandable
form of routing data.
sourceraw docstring

form-action-for-routesclj

(form-action-for-routes routes & default-options)

Like 'url-for-routes' but the returned function returns a map with the keys :action, the URL string; and :method, the HTTP verb as a lower-case string. Also, the :method-param is :_method by default, so HTTP verbs other than GET and POST will be converted to POST with the actual verb in the query string.

Like 'url-for-routes' but the returned function returns a map with the keys
:action, the URL string; and :method, the HTTP verb as a lower-case
string. Also, the :method-param is :_method by default, so HTTP
verbs other than GET and POST will be converted to POST with the
actual verb in the query string.
sourceraw docstring

method-paramclj

(method-param)
(method-param query-param-or-param-path)

Returns an interceptor that smuggles HTTP verbs through a value in the request. Must come after the interceptor that populates that value (e.g. query-params or body-params).

query-param-or-param-path may be one of two things:

  • The parameter inside :query-params where the verb will reside.
  • A complete path to a value elsewhere in the request, such as [:query-params :_method] or [:body-params "_method"]

The path [:query-params :_method] is used by default.

Returns an interceptor that smuggles HTTP verbs through a value in
the request. Must come *after* the interceptor that populates that
value (e.g. query-params or body-params).

query-param-or-param-path may be one of two things:

- The parameter inside :query-params where the verb will
  reside.
- A complete path to a value elsewhere in the request, such as
  [:query-params :_method] or [:body-params "_method"]

The path [:query-params :_method] is used by default.
sourceraw docstring

parse-param-mapclj

(parse-param-map m)
source

parse-path-paramsclj

(parse-path-params request)
source

parse-query-paramsclj

(parse-query-params request)
source

parse-query-stringclj

(parse-query-string string & options)

Parses URL query string (not including the leading '?') into a map. options are key-value pairs, valid options are:

:key-fn Function to call on parameter keys (after URL decoding), returns key for the map, default converts to a keyword.

:value-fn Function to call on the key (after passing through key-fn) and parameter value (after URL decoding), returns value for the map, default does nothing.

Parses URL query string (not including the leading '?') into a map.
options are key-value pairs, valid options are:

   :key-fn    Function to call on parameter keys (after URL
              decoding), returns key for the map, default converts
              to a keyword.

   :value-fn  Function to call on the key (after passing through
              key-fn) and parameter value (after URL decoding),
              returns value for the map, default does nothing.
sourceraw docstring

path-params-decoderclj

An Interceptor which URL-decodes path parameters. The path parameters are in the :request map as :path-parameters.

This will only operate once per interceptor chain execution, even if it appears multiple times; this prevents failures in existing applications that upgrade to Pedestal 0.6.0, as prior releases incorrectly failed to parse path parameters. Existing applications that upgrade may have this interceptor in some routes, which could yield runtime exceptions and request failures if the interceptor is executed twice.

An Interceptor which URL-decodes path parameters.
The path parameters are in the :request map as :path-parameters.

This will only operate once per interceptor chain execution, even if
it appears multiple times; this prevents failures in existing applications
that upgrade to Pedestal 0.6.0, as prior releases incorrectly failed to
parse path parameters. Existing applications that upgrade may have
this interceptor in some routes, which could yield runtime exceptions
and request failures if the interceptor is executed twice.
sourceraw docstring

(print-routes routing-table)

Prints a route table (from expand-routes) in an easier to read format.

Prints a route table (from [[expand-routes]]) in an easier to read format.
sourceraw docstring

query-paramsclj

Returns an interceptor which parses query-string parameters from an HTTP request into a map. Keys in the map are query-string parameter names, as keywords, and values are strings. The map is assoc'd into the request at :query-params.

Returns an interceptor which parses query-string parameters from an
HTTP request into a map. Keys in the map are query-string parameter
names, as keywords, and values are strings. The map is assoc'd into
the request at :query-params.
sourceraw docstring

routerclj

(router routing-table)
(router routing-table router-type)

Given the routing table and, optionally, what kind of router to construct, returns a RouterSpecification instance, from which a routing interceptor can be obtained.

router-type may be a keyword identifying a known [[router-implementation]], or function that accepts a routing table, and returns a [[Router]].

The default router type is :map-tree, which is the fastest built-in router; however, if the expanded routes contain path paramters or wildcards, the result is equivalent to the slower :prefix-tree implementation.

Given the routing table and, optionally, what kind of router to construct, returns
a RouterSpecification instance, from which a routing interceptor can be obtained.

router-type may be a keyword identifying a known [[router-implementation]], or function
that accepts a routing table, and returns a [[Router]].

The default router type is :map-tree, which is the fastest built-in router;
however, if the expanded routes contain path paramters or wildcards,
the result is equivalent to the slower :prefix-tree implementation.
sourceraw docstring

router-implementationsclj

Maps from the common router implemenations (:map-tree, :prefix-tree, or :linear-search) to a router constructor function (which accepts expanded routes, and returns a Router instance).

Maps from the common router implemenations (:map-tree, :prefix-tree, or :linear-search) to a router
constructor function (which accepts expanded routes, and returns a Router instance).
sourceraw docstring

RouterSpecificationcljprotocol

router-specclj

(router-spec routing-table router-ctor)

Returns an interceptor which attempts to match each route against a :request in context. For the first route that matches, it will:

  • enqueue the matched route's interceptors
  • associate the route into the context at :route
  • associate a map of :path-params into the :request

If no route matches, returns context with :route nil.

Returns an interceptor which attempts to match each route against
  a :request in context. For the first route that matches, it will:

  - enqueue the matched route's interceptors
  - associate the route into the context at :route
  - associate a map of :path-params into the :request

If no route matches, returns context with :route nil.
source

try-routing-forclj

(try-routing-for routing-table router-type path verb)

Used for testing; constructs a router from the routing-table and router-type and perform routing, returning the matched route (from the expanded routes), or nil if routing was unsuccessful.

Used for testing; constructs a router from the routing-table and router-type and perform routing, returning the matched
route (from the expanded routes), or nil if routing was unsuccessful.
sourceraw docstring

url-forclj

(url-for route-name & options)

Invokes currently bound contextual linker to generate url based on

  • The routing table in use.
  • The incoming request being routed.

where options are as described in url-for-routes.

Invokes currently bound contextual linker to generate url based on

  - The routing table in use.
  - The incoming request being routed.

where `options` are as described in `url-for-routes`.
sourceraw docstring

url-for-routesclj

(url-for-routes routes & default-options)

Returns a function that generates URL routes (as strings) from the routes table. The returned function has the signature:

[route-name & options]

Where 'options' are key-value pairs from:

:app-name Application name specified for this route

:request The original request; it will be merged into the generated link.

:params A map of all parameters; any params not used as path parameters will be added to the query string

:path-params A map of path parameters only

:strict-path-params? A boolean, when true will throw an exception if all path-params aren't fulfilled for the url

:query-params A map of query-string parameters only

:method-param Keyword naming the query-string parameter in which to place the HTTP method name, if it is neither GET nor POST. If nil, the HTTP method name will not be included in the query string. Default is nil.

:context A string, function that returns a string, or symbol that resolves to a function that returns a string that specifies a root context for the URL. Default is nil.

:fragment A string for the fragment part of the url.

:absolute? Boolean, whether or not to force an absolute URL

:scheme Keyword (:http | :https) used to override the scheme portion of the url.

:host A string used to override the host portion of the URL.

:port An integer used to override the port in the URL.

In addition, you may supply default-options to the 'url-for-routes' function, which are merged with the options supplied to the returned function.

Returns a function that generates URL routes (as strings) from the
routes table. The returned function has the signature:

   [route-name & options]

Where 'options' are key-value pairs from:

   :app-name      Application name specified for this route

   :request       The original request; it will be merged into the
                  generated link.

   :params        A map of all parameters; any params not used as
                  path parameters will be added to the query string

   :path-params   A map of path parameters only

   :strict-path-params? A boolean, when true will throw an exception
                        if all path-params aren't fulfilled for the url

   :query-params  A map of query-string parameters only

   :method-param  Keyword naming the query-string parameter in which
                  to place the HTTP method name, if it is neither
                  GET nor POST. If nil, the HTTP method name will
                  not be included in the query string. Default is nil.

   :context       A string, function that returns a string, or symbol
                  that resolves to a function that returns a string
                  that specifies a root context for the URL. Default
                  is nil.

   :fragment      A string for the fragment part of the url.

   :absolute?     Boolean, whether or not to force an absolute URL

   :scheme        Keyword (:http | :https) used to override the scheme
                  portion of the url.

   :host          A string used to override the host portion of the URL.

   :port          An integer used to override the port in the URL.

In addition, you may supply default-options to the 'url-for-routes'
function, which are merged with the options supplied to the returned
function.
sourceraw docstring

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close