summaryrefslogtreecommitdiffstats
path: root/docs/en/cowboy/2.12/manual/cowboy_rest/index.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/en/cowboy/2.12/manual/cowboy_rest/index.html')
-rw-r--r--docs/en/cowboy/2.12/manual/cowboy_rest/index.html741
1 files changed, 741 insertions, 0 deletions
diff --git a/docs/en/cowboy/2.12/manual/cowboy_rest/index.html b/docs/en/cowboy/2.12/manual/cowboy_rest/index.html
new file mode 100644
index 00000000..42dd6b06
--- /dev/null
+++ b/docs/en/cowboy/2.12/manual/cowboy_rest/index.html
@@ -0,0 +1,741 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
+ <meta name="description" content="">
+ <meta name="author" content="Loïc Hoguin based on a design from (Soft10) Pol Cámara">
+
+ <title>Nine Nines: cowboy_rest(3)</title>
+
+ <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'>
+ <link href="/css/99s.css?r=7" rel="stylesheet">
+
+ <link rel="shortcut icon" href="/img/ico/favicon.ico">
+ <link rel="apple-touch-icon-precomposed" sizes="114x114" href="/img/ico/apple-touch-icon-114.png">
+ <link rel="apple-touch-icon-precomposed" sizes="72x72" href="/img/ico/apple-touch-icon-72.png">
+ <link rel="apple-touch-icon-precomposed" href="/img/ico/apple-touch-icon-57.png">
+
+ </head>
+
+
+<body class="">
+ <header id="page-head">
+ <div id="topbar" class="container">
+ <div class="row">
+ <div class="span2">
+ <h1 id="logo"><a href="/" title="99s">99s</a></h1>
+ </div>
+ <div class="span10">
+
+ <div id="side-header">
+ <nav>
+ <ul>
+ <li><a title="Hear my thoughts" href="/articles">Articles</a></li>
+ <li><a title="Watch my talks" href="/talks">Talks</a></li>
+ <li class="active"><a title="Read the docs" href="/docs">Documentation</a></li>
+ <li><a title="Request my services" href="/services">Consulting & Training</a></li>
+ </ul>
+ </nav>
+ <ul id="social">
+ <li>
+ <a href="https://github.com/ninenines" title="Check my Github repositories"><img src="/img/ico_github.png" data-hover="/img/ico_github_alt.png" alt="Github"></a>
+ </li>
+ <li>
+ <a title="Contact me" href="mailto:[email protected]"><img src="/img/ico_mail.png" data-hover="/img/ico_mail_alt.png"></a>
+ </li>
+ </ul>
+ </div>
+ </div>
+ </div>
+ </div>
+
+
+</header>
+
+<div id="contents" class="two_col">
+<div class="container">
+<div class="row">
+<div id="docs" class="span9 maincol">
+
+<h1 class="lined-header"><span>cowboy_rest(3)</span></h1>
+
+<h2 id="_name">Name</h2>
+<p>cowboy_rest - REST handlers</p>
+<h2 id="_description">Description</h2>
+<p>The module <code>cowboy_rest</code> implements the HTTP state machine.</p>
+<p>Implementing REST handlers is not enough to provide a REST interface; this interface must also follow the REST constraints including HATEOAS (hypermedia as the engine of application state).</p>
+<h2 id="_callbacks">Callbacks</h2>
+<p>REST handlers implement the following interface:</p>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">init</font></b>(<font color="#009900">Req</font>, <font color="#009900">State</font>)
+ <font color="#990000">-&gt;</font> {<font color="#FF6600">cowboy_rest</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<font color="#009900">Callback</font>(<font color="#009900">Req</font>, <font color="#009900">State</font>)
+ <font color="#990000">-&gt;</font> {<font color="#009900">Result</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+ | {<font color="#FF6600">stop</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+ | {{<font color="#FF6600">switch_handler</font>, <font color="#009900">Module</font>}, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+ | {{<font color="#FF6600">switch_handler</font>, <font color="#009900">Module</font>, <font color="#009900">Opts</font>}, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<b><font color="#000000">terminate</font></b>(<font color="#009900">Reason</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> <font color="#FF6600">ok</font> <i><font color="#9A1900">%% optional</font></i>
+
+<font color="#009900">Req</font> <font color="#990000">::</font> <b><font color="#000000">cowboy_req:req</font></b>()
+<font color="#009900">State</font> <font color="#990000">::</font> <b><font color="#000000">any</font></b>()
+<font color="#009900">Module</font> <font color="#990000">::</font> <b><font color="#000000">module</font></b>()
+<font color="#009900">Opts</font> <font color="#990000">::</font> <b><font color="#000000">any</font></b>()
+<font color="#009900">Reason</font> <font color="#990000">::</font> <b><font color="#000080">normal</font></b>
+ | {<font color="#FF6600">crash</font>, <font color="#FF6600">error</font> | <b><font color="#000080">exit</font></b> | <b><font color="#000080">throw</font></b>, <b><font color="#000000">any</font></b>()}
+
+<font color="#009900">Callback</font> <font color="#990000">-</font> <font color="#FF6600">see</font> <font color="#FF6600">below</font>
+<font color="#009900">Result</font> <font color="#990000">-</font> <font color="#FF6600">see</font> <font color="#FF6600">below</font>
+<font color="#009900">Default</font> <font color="#990000">-</font> <font color="#FF6600">see</font> <font color="#FF6600">below</font></tt></pre>
+</div></div>
+<p>The <code>init/2</code> callback is common to all handlers. To switch to the REST handler behavior, it must return <code>cowboy_rest</code> as the first element of the tuple.</p>
+<p>The <code>Callback/2</code> above represents all the REST-specific callbacks. They are described in the following section of this manual. REST-specific callbacks differ by their name, semantics, result and default values. The default value is the one used when the callback has not been implemented. They otherwise all follow the same interface.</p>
+<p>The <code>stop</code> tuple can be returned to stop REST processing. If no response was sent before then, Cowboy will send a <em>204 No Content</em>. The <code>stop</code> tuple can be returned from any callback, excluding <code>expires</code>, <code>generate_etag</code>, <code>last_modified</code> and <code>variances</code>.</p>
+<p>A <code>switch_handler</code> tuple can be returned from these same callbacks to stop REST processing and switch to a different handler type. This is very useful to, for example, to stream the response body.</p>
+<p>The optional <code>terminate/3</code> callback will ultimately be called with the reason for the termination of the handler. Cowboy will terminate the process right after this. There is no need to perform any cleanup in this callback.</p>
+<p>The following terminate reasons are defined for loop handlers:</p>
+<dl><dt>normal</dt>
+<dd><p>The handler terminated normally.</p>
+</dd>
+<dt>{crash, Class, Reason}</dt>
+<dd><p>A crash occurred in the handler. <code>Class</code> and <code>Reason</code> can be used to obtain more information about the crash.</p>
+</dd>
+</dl>
+<h2 id="_rest_callbacks">REST callbacks</h2>
+<h3 id="_acceptcallback">AcceptCallback</h3>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><font color="#009900">AcceptCallback</font>(<font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> {<font color="#009900">Result</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<font color="#009900">Result</font> <font color="#990000">::</font> <font color="#000080">true</font>
+ | {<font color="#FF6600">created</font>, <font color="#009900">URI</font> <font color="#990000">::</font> <b><font color="#000000">iodata</font></b>()}
+ | {<font color="#FF6600">see_other</font>, <font color="#009900">URI</font> <font color="#990000">::</font> <b><font color="#000000">iodata</font></b>()}
+ | <font color="#000080">false</font>
+<font color="#009900">Default</font> <font color="#990000">-</font> <font color="#FF6600">crash</font></tt></pre>
+</div></div>
+<p>Process the request body.</p>
+<p>This function should create or update the resource using the request body.</p>
+<p>For PUT requests, the body is a representation of the resource that is being created or replaced.</p>
+<p>For POST requests, the body is typically application-specific instructions on how to process the request, but it may also be a representation of the resource. When creating a new resource with POST at a different location, return <code>{created, URI}</code> or <code>{see_other, URI}</code> with <code>URI</code> the new location.</p>
+<p>The <code>see_other</code> tuple will redirect the client to the new location automatically.</p>
+<p>For PATCH requests, the body is a series of instructions on how to update the resource. Patch files or JSON Patch are examples of such media types.</p>
+<p>A response body may be sent. The appropriate media type, charset and language for the response can be retrieved from the Req object using the <code>media_type</code>, <code>charset</code> and <code>language</code> keys, respectively. The body can be set using <a href="../cowboy_req.set_resp_body">cowboy_req:set_resp_body(3)</a>.</p>
+<h3 id="_allowed_methods">allowed_methods</h3>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">allowed_methods</font></b>(<font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> {<font color="#009900">Result</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<font color="#009900">Result</font> <font color="#990000">::</font> [<b><font color="#000080">binary</font></b>()] <i><font color="#9A1900">%% case sensitive</font></i>
+<font color="#009900">Default</font> <font color="#990000">::</font> [<font color="#990000">&lt;&lt;</font><font color="#FF0000">"GET"</font><font color="#990000">&gt;&gt;</font>, <font color="#990000">&lt;&lt;</font><font color="#FF0000">"HEAD"</font><font color="#990000">&gt;&gt;</font>, <font color="#990000">&lt;&lt;</font><font color="#FF0000">"OPTIONS"</font><font color="#990000">&gt;&gt;</font>]</tt></pre>
+</div></div>
+<p>Return the list of allowed methods.</p>
+<h3 id="_allow_missing_post">allow_missing_post</h3>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">allow_missing_post</font></b>(<font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> {<font color="#009900">Result</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<font color="#009900">Result</font> <font color="#990000">::</font> <b><font color="#000000">boolean</font></b>()
+<font color="#009900">Default</font> <font color="#990000">::</font> <font color="#000080">true</font></tt></pre>
+</div></div>
+<p>Return whether POST is allowed when the resource doesn&apos;t exist.</p>
+<p>Returning <code>true</code> here means that a new resource will be created. The URI for the newly created resource should be returned from the <code>AcceptCallback</code> function.</p>
+<h3 id="_charsets_provided">charsets_provided</h3>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">charsets_provided</font></b>(<font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> {<font color="#009900">Result</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<font color="#009900">Result</font> <font color="#990000">::</font> [<b><font color="#000080">binary</font></b>()] <i><font color="#9A1900">%% lowercase; case insensitive</font></i>
+<font color="#009900">Default</font> <font color="#990000">-</font> <font color="#FF6600">skip</font> <font color="#FF6600">this</font> <font color="#FF6600">step</font></tt></pre>
+</div></div>
+<p>Return the list of charsets the resource provides in order of preference.</p>
+<p>During content negotiation Cowboy will pick the most appropriate charset for the client. The client advertises charsets it prefers with the accept-charset header. When that header is missing, Cowboy picks the first charset from the resource.</p>
+<!-- @todo We should explain precisely how charsets are picked.-->
+<p>Cowboy will add the negotiated <code>charset</code> to the Req object after this step completes:</p>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">req</font></b>() <font color="#990000">::</font> #{
+ <font color="#0000FF">charset</font> <font color="#990000">=&gt;</font> <b><font color="#000080">binary</font></b>() <i><font color="#9A1900">%% lowercase; case insensitive</font></i>
+}</tt></pre>
+</div></div>
+<p>Note that Cowboy will only append the charset to the content-type header of the response if the media type is text.</p>
+<h3 id="_content_types_accepted">content_types_accepted</h3>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">content_types_accepted</font></b>(<font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> {<font color="#009900">Result</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<font color="#009900">Result</font> <font color="#990000">::</font> [{<font color="#FF6600">'*'</font> | <b><font color="#000080">binary</font></b>() | <font color="#009900">ParsedMime</font>, <font color="#009900">AcceptCallback</font> <font color="#990000">::</font> <b><font color="#000080">atom</font></b>()}]
+<font color="#009900">ParsedMime</font> <font color="#990000">::</font> {<font color="#009900">Type</font> <font color="#990000">::</font> <b><font color="#000080">binary</font></b>(), <font color="#009900">SubType</font> <font color="#990000">::</font> <b><font color="#000080">binary</font></b>(), <font color="#FF6600">'*'</font> | <font color="#009900">Params</font>}
+<font color="#009900">Params</font> <font color="#990000">::</font> [{<font color="#009900">Key</font> <font color="#990000">::</font> <b><font color="#000080">binary</font></b>(), <font color="#009900">Value</font> <font color="#990000">::</font> <b><font color="#000080">binary</font></b>()}]
+
+<font color="#009900">Default</font> <font color="#990000">-</font> <font color="#FF6600">crash</font></tt></pre>
+</div></div>
+<!-- @todo Case sensitivity of parsed mime content?-->
+<p>Return the list of media types the resource accepts in order of preference.</p>
+<p>A media type is made of different parts. The media type <code>text/html;charset=utf-8</code> is of type <code>text</code>, subtype <code>html</code> and has a single parameter <code>charset</code> with value <code>utf-8</code>.</p>
+<p>The special value <code>&apos;*&apos;</code> can be used to accept any media type.</p>
+<!-- @todo Cowboy needs to ignore the boundary parameter for-->
+<!-- multipart, as we never want to match against it. Or allow-->
+<!-- ignoring specific parameters at the very least.-->
+<p>Cowboy will match the content-type request header against the media types the server accepts and select the appropriate callback. When that header is missing, or when the server does not accept this media type, the request fails and an error response is returned. Cowboy will execute the callback immediately otherwise.</p>
+<!-- @todo We should explain precisely how media types are picked.-->
+<p>An empty parameters list <code>[]</code> means that no parameters will be accepted. When any parameter is acceptable, the tuple form should be used with parameters as the atom <code>&apos;*&apos;</code>.</p>
+<p>Cowboy treats all parameters as case sensitive, except for the <code>charset</code> parameter, which is known to be case insensitive. You should therefore always provide the charset as a lowercase binary string.</p>
+<!-- @todo Maybe this should be in the user guide instead.-->
+<!-- This function will be called for POST, PUT and PATCH requests.-->
+<!-- It is entirely possible to define different callbacks for different-->
+<!-- methods if the handling of the request differs. Simply verify-->
+<!-- what the method is with `cowboy_req:method/1` and return a-->
+<!-- different list for each methods.-->
+<h3 id="_content_types_provided">content_types_provided</h3>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">content_types_provided</font></b>(<font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> {<font color="#009900">Result</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<font color="#009900">Result</font> <font color="#990000">::</font> [{<b><font color="#000080">binary</font></b>() | <font color="#009900">ParsedMime</font>, <font color="#009900">ProvideCallback</font> <font color="#990000">::</font> <b><font color="#000080">atom</font></b>()}]
+<font color="#009900">ParsedMime</font> <font color="#990000">::</font> {<font color="#009900">Type</font> <font color="#990000">::</font> <b><font color="#000080">binary</font></b>(), <font color="#009900">SubType</font> <font color="#990000">::</font> <b><font color="#000080">binary</font></b>(), <font color="#FF6600">'*'</font> | <font color="#009900">Params</font>}
+<font color="#009900">Params</font> <font color="#990000">::</font> [{<font color="#009900">Key</font> <font color="#990000">::</font> <b><font color="#000080">binary</font></b>(), <font color="#009900">Value</font> <font color="#990000">::</font> <b><font color="#000080">binary</font></b>()}]
+
+<font color="#009900">Default</font> <font color="#990000">-</font> [{{ <font color="#990000">&lt;&lt;</font><font color="#FF0000">"text"</font><font color="#990000">&gt;&gt;</font>, <font color="#990000">&lt;&lt;</font><font color="#FF0000">"html"</font><font color="#990000">&gt;&gt;</font>, <font color="#FF6600">'*'</font>}, <font color="#FF6600">to_html</font>}]</tt></pre>
+</div></div>
+<!-- @todo Case sensitivity of parsed mime content?-->
+<!-- @todo Space required for the time being: https://github.com/spf13/hugo/issues/2398-->
+<p>Return the list of media types the resource provides in order of preference.</p>
+<p>A media type is made of different parts. The media type <code>text/html;charset=utf-8</code> is of type <code>text</code>, subtype <code>html</code> and has a single parameter <code>charset</code> with value <code>utf-8</code>.</p>
+<!-- @todo Cowboy needs to ignore the boundary parameter for-->
+<!-- multipart, as we never want to match against it. Or allow-->
+<!-- ignoring specific parameters at the very least.-->
+<p>During content negotiation Cowboy will pick the most appropriate media type for the client. The client advertises media types it prefers with the accept header. When that header is missing, the content negotiation fails and an error response is returned.</p>
+<p>The callback given for the selected media type will be called at the end of the execution of GET and HEAD requests when a representation must be sent to the client.</p>
+<!-- @todo We should explain precisely how media types are picked.-->
+<p>An empty parameters list <code>[]</code> means that no parameters will be accepted. When any parameter is acceptable, the tuple form should be used with parameters as the atom <code>&apos;*&apos;</code>.</p>
+<p>Cowboy treats all parameters as case sensitive, except for the <code>charset</code> parameter, which is known to be case insensitive. You should therefore always provide the charset as a lowercase binary string.</p>
+<p>When a charset is given in the media type parameters in the accept header, Cowboy will do some additional checks to confirm that it can use this charset. When the wildcard is used then Cowboy will immediately call <code>charsets_provided</code> to confirm the charset is acceptable. If the callback is undefined Cowboy assumes any charset is acceptable. When the wildcard is not used and the charset given in the accept header matches one of the configured media types Cowboy will use that charset and skip the <code>charsets_provided</code> step entirely.</p>
+<p>Cowboy will add the negotiated <code>media_type</code> to the Req object after this step completes:</p>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">req</font></b>() <font color="#990000">::</font> #{
+ <font color="#0000FF">media_type</font> <font color="#990000">=&gt;</font> <font color="#009900">ParsedMime</font>
+}</tt></pre>
+</div></div>
+<!-- @todo Case sensitivity of parsed mime content?-->
+<p>Cowboy may also add the negotiated <code>charset</code> to the Req object after this step completes:</p>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">req</font></b>() <font color="#990000">::</font> #{
+ <font color="#0000FF">charset</font> <font color="#990000">=&gt;</font> <b><font color="#000080">binary</font></b>() <i><font color="#9A1900">%% lowercase; case insensitive</font></i>
+}</tt></pre>
+</div></div>
+<h3 id="_delete_completed">delete_completed</h3>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">delete_completed</font></b>(<font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> {<font color="#009900">Result</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<font color="#009900">Result</font> <font color="#990000">::</font> <b><font color="#000000">boolean</font></b>()
+<font color="#009900">Default</font> <font color="#990000">::</font> <font color="#000080">true</font></tt></pre>
+</div></div>
+<p>Return whether the resource has been fully deleted from the system, including from any internal cache.</p>
+<p>Returning <code>false</code> will result in a <em>202 Accepted</em> response being sent instead of a <em>200 OK</em> or <em>204 No Content</em>.</p>
+<h3 id="_delete_resource">delete_resource</h3>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">delete_resource</font></b>(<font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> {<font color="#009900">Result</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<font color="#009900">Result</font> <font color="#990000">::</font> <b><font color="#000000">boolean</font></b>()
+<font color="#009900">Default</font> <font color="#990000">::</font> <font color="#000080">false</font></tt></pre>
+</div></div>
+<p>Delete the resource.</p>
+<p>Cowboy will send an error response when this function returns <code>false</code>.</p>
+<h3 id="_expires">expires</h3>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">expires</font></b>(<font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> {<font color="#009900">Result</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<font color="#009900">Result</font> <font color="#990000">::</font> <b><font color="#000000">calendar:datetime</font></b>() | <b><font color="#000080">binary</font></b>() | <font color="#000080">undefined</font>
+<font color="#009900">Default</font> <font color="#990000">::</font> <font color="#000080">undefined</font></tt></pre>
+</div></div>
+<p>Return the resource&apos;s expiration date.</p>
+<h3 id="_forbidden">forbidden</h3>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">forbidden</font></b>(<font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> {<font color="#009900">Result</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<font color="#009900">Result</font> <font color="#990000">::</font> <b><font color="#000000">boolean</font></b>()
+<font color="#009900">Default</font> <font color="#990000">::</font> <font color="#000080">false</font></tt></pre>
+</div></div>
+<p>Return whether access to the resource is forbidden.</p>
+<p>A <em>403 Forbidden</em> response will be sent if this function returns <code>true</code>. This status code means that access is forbidden regardless of authentication, and that the request shouldn&apos;t be repeated.</p>
+<h3 id="_generate_etag">generate_etag</h3>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">generate_etag</font></b>(<font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> {<font color="#009900">Result</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<font color="#009900">Result</font> <font color="#990000">::</font> <b><font color="#000080">binary</font></b>() | {<font color="#FF6600">weak</font> | <font color="#FF6600">strong</font>, <b><font color="#000080">binary</font></b>()} | <font color="#000080">undefined</font>
+<font color="#009900">Default</font> <font color="#990000">-</font> <font color="#FF6600">no</font> <font color="#FF6600">etag</font> <font color="#FF6600">value</font></tt></pre>
+</div></div>
+<p>Return the entity tag of the resource.</p>
+<p>When a binary is returned, the value is automatically parsed to a tuple. The binary must be in the same format as the etag header, including quotes.</p>
+<p>It is possible to conditionally generate an etag. When no etag can be generated, <code>undefined</code> should be returned.</p>
+<h3 id="_is_authorized">is_authorized</h3>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">is_authorized</font></b>(<font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> {<font color="#009900">Result</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<font color="#009900">Result</font> <font color="#990000">::</font> <font color="#000080">true</font> | {<font color="#000080">false</font>, <font color="#009900">AuthHeader</font> <font color="#990000">::</font> <b><font color="#000000">iodata</font></b>()}
+<font color="#009900">Default</font> <font color="#990000">-</font> <font color="#000080">true</font></tt></pre>
+</div></div>
+<p>Return whether the user is authorized to perform the action.</p>
+<p>This function should be used to perform any necessary authentication of the user before attempting to perform any action on the resource.</p>
+<p>When authentication fails, the <code>AuthHeader</code> value will be sent in the www-authenticate header for the <em>401 Unauthorized</em> response.</p>
+<h3 id="_is_conflict">is_conflict</h3>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">is_conflict</font></b>(<font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> {<font color="#009900">Result</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<font color="#009900">Result</font> <font color="#990000">::</font> <b><font color="#000000">boolean</font></b>()
+<font color="#009900">Default</font> <font color="#990000">::</font> <font color="#000080">false</font></tt></pre>
+</div></div>
+<p>Return whether the PUT request results in a conflict.</p>
+<p>A <em>409 Conflict</em> response is sent when <code>true</code>.</p>
+<h3 id="_known_methods">known_methods</h3>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">known_methods</font></b>(<font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> {<font color="#009900">Result</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<font color="#009900">Result</font> <font color="#990000">::</font> [<b><font color="#000080">binary</font></b>()] <i><font color="#9A1900">%% case sensitive</font></i>
+<font color="#009900">Default</font> <font color="#990000">::</font> [<font color="#990000">&lt;&lt;</font><font color="#FF0000">"GET"</font><font color="#990000">&gt;&gt;</font>, <font color="#990000">&lt;&lt;</font><font color="#FF0000">"HEAD"</font><font color="#990000">&gt;&gt;</font>, <font color="#990000">&lt;&lt;</font><font color="#FF0000">"POST"</font><font color="#990000">&gt;&gt;</font>, <font color="#990000">&lt;&lt;</font><font color="#FF0000">"PUT"</font><font color="#990000">&gt;&gt;</font>,
+ <font color="#990000">&lt;&lt;</font><font color="#FF0000">"PATCH"</font><font color="#990000">&gt;&gt;</font>, <font color="#990000">&lt;&lt;</font><font color="#FF0000">"DELETE"</font><font color="#990000">&gt;&gt;</font>, <font color="#990000">&lt;&lt;</font><font color="#FF0000">"OPTIONS"</font><font color="#990000">&gt;&gt;</font>]</tt></pre>
+</div></div>
+<p>Return the list of known methods.</p>
+<p>The full list of methods known by the server should be returned, regardless of their use in the resource.</p>
+<p>The default value lists the methods Cowboy knows and implement in <code>cowboy_rest</code>.</p>
+<h3 id="_languages_provided">languages_provided</h3>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">languages_provided</font></b>(<font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> {<font color="#009900">Result</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<font color="#009900">Result</font> <font color="#990000">::</font> [<b><font color="#000080">binary</font></b>()] <i><font color="#9A1900">%% lowercase; case insensitive</font></i>
+<font color="#009900">Default</font> <font color="#990000">-</font> <font color="#FF6600">skip</font> <font color="#FF6600">this</font> <font color="#FF6600">step</font></tt></pre>
+</div></div>
+<p>Return the list of languages the resource provides in order of preference.</p>
+<p>During content negotiation Cowboy will pick the most appropriate language for the client. The client advertises languages it prefers with the accept-language header. When that header is missing, Cowboy picks the first language from the resource.</p>
+<!-- @todo We should explain precisely how languages are picked.-->
+<p>Cowboy will add the negotiated <code>language</code> to the Req object after this step completes:</p>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">req</font></b>() <font color="#990000">::</font> #{
+ <font color="#0000FF">language</font> <font color="#990000">=&gt;</font> <b><font color="#000080">binary</font></b>() <i><font color="#9A1900">%% lowercase; case insensitive</font></i>
+}</tt></pre>
+</div></div>
+<h3 id="_last_modified">last_modified</h3>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">last_modified</font></b>(<font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> {<font color="#009900">Result</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<font color="#009900">Result</font> <font color="#990000">::</font> <b><font color="#000000">calendar:datetime</font></b>()
+<font color="#009900">Default</font> <font color="#990000">-</font> <font color="#FF6600">no</font> <font color="#FF6600">last</font> <font color="#FF6600">modified</font> <font color="#FF6600">value</font></tt></pre>
+</div></div>
+<p>Return the resource&apos;s last modification date.</p>
+<p>This date will be used to test against the if-modified-since and if-unmodified-since headers, and sent as the last-modified header in the response to GET and HEAD requests.</p>
+<h3 id="_malformed_request">malformed_request</h3>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">malformed_request</font></b>(<font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> {<font color="#009900">Result</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<font color="#009900">Result</font> <font color="#990000">::</font> <b><font color="#000000">boolean</font></b>()
+<font color="#009900">Default</font> <font color="#990000">::</font> <font color="#000080">false</font></tt></pre>
+</div></div>
+<p>Return whether the request is malformed.</p>
+<p>A request is malformed when a component required by the resource is invalid. This may include the query string or individual headers. They should be parsed and validated in this function. The body should not be read at this point.</p>
+<h3 id="_moved_permanently">moved_permanently</h3>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">moved_permanently</font></b>(<font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> {<font color="#009900">Result</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<font color="#009900">Result</font> <font color="#990000">::</font> {<font color="#000080">true</font>, <font color="#009900">URI</font> <font color="#990000">::</font> <b><font color="#000000">iodata</font></b>()} | <font color="#000080">false</font>
+<font color="#009900">Default</font> <font color="#990000">::</font> <font color="#000080">false</font></tt></pre>
+</div></div>
+<p>Return whether the resource was permanently moved, and what its new location is.</p>
+<h3 id="_moved_temporarily">moved_temporarily</h3>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">moved_temporarily</font></b>(<font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> {<font color="#009900">Result</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<font color="#009900">Result</font> <font color="#990000">::</font> {<font color="#000080">true</font>, <font color="#009900">URI</font> <font color="#990000">::</font> <b><font color="#000000">iodata</font></b>()} | <font color="#000080">false</font>
+<font color="#009900">Default</font> <font color="#990000">::</font> <font color="#000080">false</font></tt></pre>
+</div></div>
+<p>Return whether the resource was temporarily moved, and what its new location is.</p>
+<h3 id="_multiple_choices">multiple_choices</h3>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">multiple_choices</font></b>(<font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> {<font color="#009900">Result</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<font color="#009900">Result</font> <font color="#990000">::</font> <b><font color="#000000">boolean</font></b>()
+<font color="#009900">Default</font> <font color="#990000">::</font> <font color="#000080">false</font></tt></pre>
+</div></div>
+<p>Return whether the client should engage in reactive negotiation.</p>
+<p>Return <code>true</code> when the server has multiple representations of a resource, each with their specific identifier, but is unable to determine which is best for the client. For example an image might have different sizes and the server is unable to determine the capabilities of the client.</p>
+<p>When returning <code>true</code> the server should send a body with links to the different representations. If the server has a preferred representation it can send its link inside a location header.</p>
+<p>Note that when replying manually in this callback you should either call <code>cowboy_req:reply/4</code> or remove the response body that Cowboy sets to avoid surprises.</p>
+<h3 id="_options">options</h3>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">options</font></b>(<font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> {<font color="#FF6600">ok</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}</tt></pre>
+</div></div>
+<p>Respond to an OPTIONS request.</p>
+<p>The response should inform the client the communication options available for this resource. By default Cowboy will send a <em>200 OK</em> response with the allow header set.</p>
+<h3 id="_previously_existed">previously_existed</h3>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">previously_existed</font></b>(<font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> {<font color="#009900">Result</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<font color="#009900">Result</font> <font color="#990000">::</font> <b><font color="#000000">boolean</font></b>()
+<font color="#009900">Default</font> <font color="#990000">::</font> <font color="#000080">false</font></tt></pre>
+</div></div>
+<p>Return whether the resource existed previously.</p>
+<h3 id="_providecallback">ProvideCallback</h3>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><font color="#009900">ProvideCallback</font>(<font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> {<font color="#009900">Result</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<font color="#009900">Result</font> <font color="#990000">::</font> <b><font color="#000000">cowboy_req:resp_body</font></b>()
+<font color="#009900">Default</font> <font color="#990000">-</font> <font color="#FF6600">crash</font></tt></pre>
+</div></div>
+<p>Return the response body.</p>
+<p>The response body can be provided either as the actual data to be sent or a tuple indicating which file to send.</p>
+<p>This function is called for both GET and HEAD requests. For the latter the body is not sent: it is only used to calculate the content length.</p>
+<!-- @todo Perhaps we can optimize HEAD requests and just-->
+<!-- allow calculating the length instead of returning the-->
+<!-- whole thing.-->
+<p>It is possible to stream the response body either by manually sending the response and returning a <code>stop</code> value; or by switching to a different handler (for example a loop handler) and manually sending the response. All headers already set by Cowboy will also be included in the response.</p>
+<h2 id="_rangecallback">RangeCallback</h2>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><font color="#009900">RangeCallback</font>(<font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> {<font color="#009900">Result</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<font color="#009900">Result</font> <font color="#990000">::</font> [{<font color="#009900">Range</font>, <font color="#009900">Body</font>}]
+<font color="#009900">Range</font> <font color="#990000">::</font> {<font color="#009900">From</font>, <font color="#009900">To</font>, <font color="#009900">Total</font>} | <b><font color="#000080">binary</font></b>()
+<font color="#009900">From</font> <font color="#990000">::</font> <b><font color="#000000">non_neg_integer</font></b>()
+<font color="#009900">To</font> <font color="#990000">::</font> <b><font color="#000000">non_neg_integer</font></b>()
+<font color="#009900">Total</font> <font color="#990000">::</font> <b><font color="#000000">non_neg_integer</font></b>() | <font color="#FF6600">'*'</font>
+<font color="#009900">Body</font> <font color="#990000">::</font> <b><font color="#000000">cowboy_req:resp_body</font></b>()
+<font color="#009900">Default</font> <font color="#990000">-</font> <font color="#FF6600">crash</font></tt></pre>
+</div></div>
+<p>Return a list of ranges for the response body.</p>
+<p>The range selected can be found in the key <code>range</code> in the Req object, as indicated in <code>range_satisfiable</code>.</p>
+<p>Instead of returning the full response body as would be done in the <code>ProvideCallback</code>, a list of ranges must be returned. There can be one or more range. When one range is returned, a normal ranged response is sent. When multiple ranges are returned, Cowboy will automatically send a multipart/byteranges response.</p>
+<p>When the total is not known the atom <code>&apos;*&apos;</code> can be returned.</p>
+<h2 id="_ranges_provided">ranges_provided</h2>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">ranges_provided</font></b>(<font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> {<font color="#009900">Result</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<font color="#009900">Result</font> <font color="#990000">::</font> [<font color="#009900">Range</font> | <font color="#009900">Auto</font>]
+<font color="#009900">Range</font> <font color="#990000">::</font> {
+ <b><font color="#000080">binary</font></b>(), <i><font color="#9A1900">%% lowercase; case insensitive</font></i>
+ <font color="#009900">RangeCallback</font> <font color="#990000">::</font> <b><font color="#000080">atom</font></b>()
+}
+<font color="#009900">Auto</font> <font color="#990000">::</font> {<font color="#990000">&lt;&lt;</font><font color="#FF0000">"bytes"</font><font color="#990000">&gt;&gt;</font>, <font color="#FF6600">auto</font>}
+<font color="#009900">Default</font> <font color="#990000">-</font> <font color="#FF6600">skip</font> <font color="#FF6600">this</font> <font color="#FF6600">step</font></tt></pre>
+</div></div>
+<p>Return the list of range units the resource provides.</p>
+<p>During content negotiation Cowboy will build an accept-ranges response header with the list of ranges provided. Cowboy does not choose a range at this time; ranges are choosen when it comes time to call the <code>ProvideCallback</code>.</p>
+<p>By default ranged requests will be handled the same as normal requests: the <code>ProvideCallback</code> will be called and the full response body will be sent.</p>
+<p>It is possible to let Cowboy handle ranged responses automatically when the range unit is bytes and the atom returned is <code>auto</code> (instead of a callback name). In that case Cowboy will call the <code>ProvideCallback</code> and split the response automatically, including by producing a multipart/byteranges response if necessary.</p>
+<h2 id="_range_satisfiable">range_satisfiable</h2>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">range_satisfiable</font></b>(<font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> {<font color="#009900">Result</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<font color="#009900">Result</font> <font color="#990000">::</font> <b><font color="#000000">boolean</font></b>() | {<font color="#000080">false</font>, <b><font color="#000000">non_neg_integer</font></b>() | <b><font color="#000000">iodata</font></b>()}
+<font color="#009900">Default</font> <font color="#990000">::</font> <font color="#000080">true</font></tt></pre>
+</div></div>
+<p>Whether the range request is satisfiable.</p>
+<p>When the time comes to send the response body, and when ranges have been provided via the <code>ranges_provided</code> callback, Cowboy will process the if-range and the range request headers and ensure it is satisfiable.</p>
+<p>This callback allows making resource-specific checks before sending the ranged response. The default is to accept sending a ranged response.</p>
+<p>Cowboy adds the requested <code>range</code> to the Req object just before calling this callback:</p>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">req</font></b>() <font color="#990000">::</font> #{
+ <font color="#0000FF">range</font> <font color="#990000">=&gt;</font> {
+ <b><font color="#000080">binary</font></b>(), <i><font color="#9A1900">%% lowercase; case insensitive</font></i>
+ <font color="#009900">Range</font>
+ }
+}
+
+<font color="#009900">Range</font> <font color="#990000">::</font> <font color="#009900">ByteRange</font> | <b><font color="#000080">binary</font></b>()
+
+<font color="#009900">ByteRange</font> <font color="#990000">::</font> [{<font color="#009900">FirstByte</font>, <font color="#009900">LastByte</font> | <font color="#FF6600">infinity</font>} | <font color="#009900">SuffixLen</font>]
+<font color="#009900">FirstByte</font> <font color="#990000">::</font> <b><font color="#000000">non_neg_integer</font></b>()
+<font color="#009900">LastByte</font> <font color="#990000">::</font> <b><font color="#000000">non_neg_integer</font></b>()
+<font color="#009900">SuffixLen</font> <font color="#990000">::</font> <b><font color="#000000">neg_integer</font></b>()</tt></pre>
+</div></div>
+<p>Only byte ranges are parsed. Other ranges are provided as binary. Byte ranges may either be requested from first to last bytes (inclusive); from first bytes to the end (<code>infinity</code> is used to represent the last byte); or the last bytes of the representation via a negative integer (so -500 means the last 500 bytes).</p>
+<p>Returning <code>false</code> will result in a 416 Range Not Satisfiable response being sent. The content-range header will be set automatically in the response if a tuple is returned. The integer value represents the total size (in the choosen unit) of the resource. An iodata value may also be returned and will be used as-is to build the content range header, prepended with the unit choosen.</p>
+<h3 id="_rate_limited">rate_limited</h3>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">rate_limited</font></b>(<font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> {<font color="#009900">Result</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<font color="#009900">Result</font> <font color="#990000">::</font> <font color="#000080">false</font> | {<font color="#000080">true</font>, <font color="#009900">RetryAfter</font>}
+<font color="#009900">RetryAfter</font> <font color="#990000">::</font> <b><font color="#000000">non_neg_integer</font></b>() | <b><font color="#000000">calendar:datetime</font></b>()
+<font color="#009900">Default</font> <font color="#990000">::</font> <font color="#000080">false</font></tt></pre>
+</div></div>
+<p>Return whether the user is rate limited.</p>
+<p>This function can be used to temporarily restrict access to a resource when the user has issued too many requests.</p>
+<p>When the resource is rate limited the <code>RetryAfter</code> value will be sent in the retry-after header for the <em>429 Too Many Requests</em> response. It indicates when the resource will become available again and can be specified as a number of seconds in the future or a specific date/time.</p>
+<h3 id="_resource_exists">resource_exists</h3>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">resource_exists</font></b>(<font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> {<font color="#009900">Result</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<font color="#009900">Result</font> <font color="#990000">::</font> <b><font color="#000000">boolean</font></b>()
+<font color="#009900">Default</font> <font color="#990000">::</font> <font color="#000080">true</font></tt></pre>
+</div></div>
+<p>Return whether the resource exists.</p>
+<h3 id="_service_available">service_available</h3>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">service_available</font></b>(<font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> {<font color="#009900">Result</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<font color="#009900">Result</font> <font color="#990000">::</font> <b><font color="#000000">boolean</font></b>()
+<font color="#009900">Default</font> <font color="#990000">::</font> <font color="#000080">true</font></tt></pre>
+</div></div>
+<p>Return whether the service is available.</p>
+<p>A <em>503 Service Unavailable</em> response will be sent when this function returns <code>false</code>.</p>
+<h3 id="_uri_too_long">uri_too_long</h3>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">uri_too_long</font></b>(<font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> {<font color="#009900">Result</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<font color="#009900">Result</font> <font color="#990000">::</font> <b><font color="#000000">boolean</font></b>()
+<font color="#009900">Default</font> <font color="#990000">::</font> <font color="#000080">false</font></tt></pre>
+</div></div>
+<p>Return whether the requested URI is too long.</p>
+<p>This function can be used to further restrict the length of the URI for this specific resource.</p>
+<h3 id="_valid_content_headers">valid_content_headers</h3>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">valid_content_headers</font></b>(<font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> {<font color="#009900">Result</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<font color="#009900">Result</font> <font color="#990000">::</font> <b><font color="#000000">boolean</font></b>()
+<font color="#009900">Default</font> <font color="#990000">::</font> <font color="#000080">true</font></tt></pre>
+</div></div>
+<p>Return whether the content headers are valid.</p>
+<p>This callback can be used to reject requests that have invalid content header values, for example an unsupported content-encoding.</p>
+<h3 id="_valid_entity_length">valid_entity_length</h3>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">valid_entity_length</font></b>(<font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> {<font color="#009900">Result</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<font color="#009900">Result</font> <font color="#990000">::</font> <b><font color="#000000">boolean</font></b>()
+<font color="#009900">Default</font> <font color="#990000">::</font> <font color="#000080">true</font></tt></pre>
+</div></div>
+<p>Return whether the request body length is within acceptable boundaries.</p>
+<p>A <em>413 Request Entity Too Large</em> response will be sent if this function returns <code>false</code>.</p>
+<h3 id="_variances">variances</h3>
+<div class="listingblock"><div class="content"><!-- Generator: GNU source-highlight 3.1.9
+by Lorenzo Bettini
+http://www.lorenzobettini.it
+http://www.gnu.org/software/src-highlite -->
+<pre><tt><b><font color="#000000">variances</font></b>(<font color="#009900">Req</font>, <font color="#009900">State</font>) <font color="#990000">-&gt;</font> {<font color="#009900">Result</font>, <font color="#009900">Req</font>, <font color="#009900">State</font>}
+
+<font color="#009900">Result</font> <font color="#990000">::</font> [<b><font color="#000080">binary</font></b>()] <i><font color="#9A1900">%% case insensitive</font></i>
+<font color="#009900">Default</font> <font color="#990000">::</font> []</tt></pre>
+</div></div>
+<p>Return the list of request headers that affect the representation of the resource.</p>
+<p>Cowboy automatically adds the accept, accept-charset and accept-language headers when necessary. It&apos;s also useful to note that some standard headers also do not need to be listed here, like the authorization header.</p>
+<h2 id="_changelog">Changelog</h2>
+<ul><li><strong>2.11</strong>: The <code>ranges_provided</code>, <code>range_satisfiable</code> and the <code>RangeCallback</code> callbacks have been added.
+</li>
+<li><strong>2.11</strong>: The <code>generate_etag</code> callback can now return <code>undefined</code> to conditionally avoid generating an etag.
+</li>
+<li><strong>2.9</strong>: An <code>AcceptCallback</code> can now return <code>{created, URI}</code> or <code>{see_other, URI}</code>. The return value <code>{true, URI}</code> is deprecated.
+</li>
+<li><strong>2.7</strong>: The media type wildcard in <code>content_types_accepted</code> is now documented.
+</li>
+<li><strong>2.6</strong>: The callback <code>rate_limited</code> was added.
+</li>
+<li><strong>2.1</strong>: The <code>switch_handler</code> return value was added.
+</li>
+<li><strong>1.0</strong>: Behavior introduced.
+</li>
+</ul>
+<h2 id="_see_also">See also</h2>
+<p><a href="..">cowboy(7)</a>, <a href="../cowboy_handler">cowboy_handler(3)</a></p>
+
+
+
+
+
+
+</div>
+
+<div class="span3 sidecol">
+
+
+<h3>
+ Cowboy
+ 2.12
+ Function Reference
+
+</h3>
+
+<ul>
+
+ <li><a href="/docs/en/cowboy/2.12/guide">User Guide</a></li>
+
+
+ <li><a href="/docs/en/cowboy/2.12/manual">Function Reference</a></li>
+
+
+</ul>
+
+<h4 id="docs-nav">Navigation</h4>
+
+<h4>Version select</h4>
+<ul>
+
+
+
+ <li><a href="/docs/en/cowboy/2.12/manual">2.12</a></li>
+
+ <li><a href="/docs/en/cowboy/2.11/manual">2.11</a></li>
+
+ <li><a href="/docs/en/cowboy/2.10/manual">2.10</a></li>
+
+ <li><a href="/docs/en/cowboy/2.9/manual">2.9</a></li>
+
+ <li><a href="/docs/en/cowboy/2.8/manual">2.8</a></li>
+
+ <li><a href="/docs/en/cowboy/2.7/manual">2.7</a></li>
+
+ <li><a href="/docs/en/cowboy/2.6/manual">2.6</a></li>
+
+</ul>
+
+<h3 id="_like_my_work__donate">Like my work? Donate!</h3>
+<p>Donate to Loïc Hoguin because his work on Cowboy, Ranch, Gun and Erlang.mk is fantastic:</p>
+<form action="https://www.paypal.com/cgi-bin/webscr" method="post" style="display:inline">
+<input type="hidden" name="cmd" value="_donations">
+<input type="hidden" name="business" value="[email protected]">
+<input type="hidden" name="lc" value="FR">
+<input type="hidden" name="item_name" value="Loic Hoguin">
+<input type="hidden" name="item_number" value="99s">
+<input type="hidden" name="currency_code" value="EUR">
+<input type="hidden" name="bn" value="PP-DonationsBF:btn_donate_LG.gif:NonHosted">
+<input type="image" src="https://www.paypalobjects.com/en_US/i/btn/btn_donate_LG.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online!">
+<img alt="" border="0" src="https://www.paypalobjects.com/fr_FR/i/scr/pixel.gif" width="1" height="1">
+</form><p>Recurring payment options are also available via <a href="https://github.com/sponsors/essen">GitHub Sponsors</a>. These funds are used to cover the recurring expenses like food, dedicated servers or domain names.</p>
+
+
+
+</div>
+</div>
+</div>
+</div>
+
+ <footer>
+ <div class="container">
+ <div class="row">
+ <div class="span6">
+ <p id="scroll-top"><a href="#">↑ Scroll to top</a></p>
+ <nav>
+ <ul>
+ <li><a href="mailto:[email protected]" title="Contact us">Contact us</a></li><li><a href="https://github.com/ninenines/ninenines.github.io" title="Github repository">Contribute to this site</a></li>
+ </ul>
+ </nav>
+ </div>
+ <div class="span6 credits">
+ <p><img src="/img/footer_logo.png"></p>
+ <p>Copyright &copy; Loïc Hoguin 2012-2018</p>
+ </div>
+ </div>
+ </div>
+ </footer>
+
+
+ <script src="/js/custom.js"></script>
+ </body>
+</html>
+
+