<commit_before>= cowboy_router:compile(3)

== Name

cowboy_router:compile - Compile routes to the resources

== Description

[source,erlang]
----
compile(cowboy_router:routes()) -> cowboy_router:dispatch_rules()
----

Compile routes to the resources.

Takes a human readable list of routes and transforms it
into a form more efficient to process.

== Arguments

Routes::

Human readable list of routes.

== Return value

An opaque dispatch rules value is returned. This value
must be given to Cowboy as a middleware environment value.

== Changelog

* *1.0*: Function introduced.

== Examples

.Compile routes and start a listener
[source,erlang]
----
Dispatch = cowboy_router:compile([
    {'_', [
        {"/", toppage_h, []},
        {"/[...], cowboy_static, {priv_dir, my_example_app, ""}}
    ]}
]),

{ok, _} = cowboy:start_clear(example, [{port, 8080}], #{
    env => #{dispatch => Dispatch}<commit_msg>Fix an example missing a " in the manual<commit_after>= cowboy_router:compile(3)

== Name

cowboy_router:compile - Compile routes to the resources

== Description

[source,erlang]
----
compile(cowboy_router:routes()) -> cowboy_router:dispatch_rules()
----

Compile routes to the resources.

Takes a human readable list of routes and transforms it
into a form more efficient to process.

== Arguments

Routes::

Human readable list of routes.

== Return value

An opaque dispatch rules value is returned. This value
must be given to Cowboy as a middleware environment value.

== Changelog

* *1.0*: Function introduced.

== Examples

.Compile routes and start a listener
[source,erlang]
----
Dispatch = cowboy_router:compile([
    {'_', [
        {"/", toppage_h, []},
        {"/[...]", cowboy_static, {priv_dir, my_example_app, ""}}
    ]}
]),

{ok, _} = cowboy:start_clear(example, [{port, 8080}], #{
    env => #{dispatch => Dispatch}
{'fraction_non_alphanumeric': 0.13759479956663057, 'fraction_numerical': 0.007583965330444204, 'mean_word_length': 3.8992042440318304, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5891192', 'n_tokens_mistral': 599, 'n_tokens_neox': 577, 'n_words': 182}