diff options
Diffstat (limited to 'docs/en/cowboy/2.4/manual/cowboy_middleware/index.html')
-rw-r--r-- | docs/en/cowboy/2.4/manual/cowboy_middleware/index.html | 123 |
1 files changed, 32 insertions, 91 deletions
diff --git a/docs/en/cowboy/2.4/manual/cowboy_middleware/index.html b/docs/en/cowboy/2.4/manual/cowboy_middleware/index.html index e7e7de29..8d5a30ad 100644 --- a/docs/en/cowboy/2.4/manual/cowboy_middleware/index.html +++ b/docs/en/cowboy/2.4/manual/cowboy_middleware/index.html @@ -62,115 +62,56 @@ <h1 class="lined-header"><span>cowboy_middleware(3)</span></h1> -<div class="sect1"> <h2 id="_name">Name</h2> -<div class="sectionbody"> -<div class="paragraph"><p>cowboy_middleware - Middlewares</p></div> -</div> -</div> -<div class="sect1"> +<p>cowboy_middleware - Middlewares</p> <h2 id="_description">Description</h2> -<div class="sectionbody"> -<div class="paragraph"><p>The module <code>cowboy_middleware</code> defines a callback interface for -Cowboy middlewares.</p></div> -<div class="paragraph"><p>Middlewares process the request sequentially in the order they -are configured.</p></div> -</div> -</div> -<div class="sect1"> +<p>The module <code>cowboy_middleware</code> defines a callback interface for Cowboy middlewares.</p> +<p>Middlewares process the request sequentially in the order they are configured.</p> <h2 id="_callbacks">Callbacks</h2> -<div class="sectionbody"> -<div class="paragraph"><p>Middlewares implement the following interface:</p></div> -<div class="listingblock"> -<div class="content"><!-- Generator: GNU source-highlight +<p>Middlewares implement the following interface:</p> +<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.8 by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -<pre><tt><span style="font-weight: bold"><span style="color: #000000">execute</span></span>(<span style="color: #009900">Req</span>, <span style="color: #009900">Env</span>) - <span style="color: #990000">-></span> {<span style="color: #FF6600">ok</span>, <span style="color: #009900">Req</span>, <span style="color: #009900">Env</span>} - | {<span style="color: #FF6600">suspend</span>, <span style="font-weight: bold"><span style="color: #000000">module</span></span>(), <span style="font-weight: bold"><span style="color: #000080">atom</span></span>(), [<span style="font-weight: bold"><span style="color: #000000">any</span></span>()]} - | {<span style="color: #FF6600">stop</span>, <span style="color: #009900">Req</span>} - -<span style="color: #009900">Req</span> <span style="color: #990000">::</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:req</span></span>() -<span style="color: #009900">Env</span> <span style="color: #990000">::</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_middleware:env</span></span>()</tt></pre></div></div> -<div class="paragraph"><p>The <code>execute/2</code> is the only callback that needs to be -implemented. It must execute the middleware and return -with instructions for Cowboy.</p></div> -<div class="dlist"><dl> -<dt class="hdlist1"> -ok -</dt> -<dd> -<p> -Cowboy should continue processing the request using the -returned Req object and environment. -</p> +<pre><tt><b><font color="#000000">execute</font></b>(<font color="#009900">Req</font>, <font color="#009900">Env</font>) + <font color="#990000">-></font> {<font color="#FF6600">ok</font>, <font color="#009900">Req</font>, <font color="#009900">Env</font>} + | {<font color="#FF6600">suspend</font>, <b><font color="#000000">module</font></b>(), <b><font color="#000080">atom</font></b>(), [<b><font color="#000000">any</font></b>()]} + | {<font color="#FF6600">stop</font>, <font color="#009900">Req</font>} + +<font color="#009900">Req</font> <font color="#990000">::</font> <b><font color="#000000">cowboy_req:req</font></b>() +<font color="#009900">Env</font> <font color="#990000">::</font> <b><font color="#000000">cowboy_middleware:env</font></b>()</tt></pre> +</div></div> +<p>The <code>execute/2</code> is the only callback that needs to be implemented. It must execute the middleware and return with instructions for Cowboy.</p> +<dl><dt>ok</dt> +<dd><p>Cowboy should continue processing the request using the returned Req object and environment.</p> </dd> -<dt class="hdlist1"> -suspend -</dt> -<dd> -<p> -Cowboy will hibernate the process. When resuming, Cowboy -will apply the returned module, function and arguments. -</p> +<dt>suspend</dt> +<dd><p>Cowboy will hibernate the process. When resuming, Cowboy will apply the returned module, function and arguments.</p> </dd> -<dt class="hdlist1"> -stop -</dt> -<dd> -<p> -Cowboy will stop middleware execution. No other middleware -will be executed. This effectively ends the processing of -the request. -</p> +<dt>stop</dt> +<dd><p>Cowboy will stop middleware execution. No other middleware will be executed. This effectively ends the processing of the request.</p> </dd> -</dl></div> -</div> -</div> -<div class="sect1"> +</dl> <h2 id="_types">Types</h2> -<div class="sectionbody"> -<div class="sect2"> <h3 id="_env">env()</h3> -<div class="listingblock"> -<div class="content"><!-- Generator: GNU source-highlight +<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.8 by Lorenzo Bettini http://www.lorenzobettini.it http://www.gnu.org/software/src-highlite --> -<pre><tt><span style="font-weight: bold"><span style="color: #000000">env</span></span>() <span style="color: #990000">::</span> #{<span style="font-weight: bold"><span style="color: #000080">atom</span></span>() <span style="color: #990000">=></span> <span style="font-weight: bold"><span style="color: #000000">any</span></span>()}</tt></pre></div></div> -<div class="paragraph"><p>Middleware environment.</p></div> -<div class="paragraph"><p>A new environment is created for every request. The initial -environment contained the user configured environment values -(like <code>dispatch</code> for example) plus the <code>listener</code> value which -contains the name of the listener for this connection.</p></div> -<div class="paragraph"><p>Middlewares may modify the environment as necessary.</p></div> -</div> -</div> -</div> -<div class="sect1"> +<pre><tt><b><font color="#000000">env</font></b>() <font color="#990000">::</font> #{<b><font color="#000080">atom</font></b>() <font color="#990000">=></font> <b><font color="#000000">any</font></b>()}</tt></pre> +</div></div> +<p>Middleware environment.</p> +<p>A new environment is created for every request. The initial environment contained the user configured environment values (like <code>dispatch</code> for example) plus the <code>listener</code> value which contains the name of the listener for this connection.</p> +<p>Middlewares may modify the environment as necessary.</p> <h2 id="_changelog">Changelog</h2> -<div class="sectionbody"> -<div class="ulist"><ul> -<li> -<p> -<strong>2.0</strong>: The <code>env</code> type is now a map instead of a proplist. -</p> +<ul><li><strong>2.0</strong>: The <code>env</code> type is now a map instead of a proplist. </li> -<li> -<p> -<strong>1.0</strong>: Behavior introduced. -</p> +<li><strong>1.0</strong>: Behavior introduced. </li> -</ul></div> -</div> -</div> -<div class="sect1"> +</ul> <h2 id="_see_also">See also</h2> -<div class="sectionbody"> -<div class="paragraph"><p><a href="..">cowboy(7)</a></p></div> -</div> -</div> +<p><a href="..">cowboy(7)</a></p> + |