diff options
author | Loïc Hoguin <[email protected]> | 2016-03-28 15:36:42 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2016-03-28 15:36:42 +0200 |
commit | fe3492a98de29942477b061cd02c92246f4bf85a (patch) | |
tree | 2255b796a657e6e4dfb72beec1141258d17f1220 /docs/en/cowboy/2.0/guide | |
download | ninenines.eu-fe3492a98de29942477b061cd02c92246f4bf85a.tar.gz ninenines.eu-fe3492a98de29942477b061cd02c92246f4bf85a.tar.bz2 ninenines.eu-fe3492a98de29942477b061cd02c92246f4bf85a.zip |
Initial commit, new website system
Diffstat (limited to 'docs/en/cowboy/2.0/guide')
71 files changed, 22688 insertions, 0 deletions
diff --git a/docs/en/cowboy/2.0/guide/architecture.asciidoc b/docs/en/cowboy/2.0/guide/architecture.asciidoc new file mode 100644 index 00000000..416ef36b --- /dev/null +++ b/docs/en/cowboy/2.0/guide/architecture.asciidoc @@ -0,0 +1,48 @@ +[[architecture]] +== Architecture + +Cowboy is a lightweight HTTP server. + +It is built on top of Ranch. Please see the Ranch guide for more +information. + +=== One process per connection + +It uses only one process per connection. The process where your +code runs is the process controlling the socket. Using one process +instead of two allows for lower memory usage. + +Because there can be more than one request per connection with the +keepalive feature of HTTP/1.1, that means the same process will be +used to handle many requests. + +Because of this, you are expected to make sure your process cleans +up before terminating the handling of the current request. This may +include cleaning up the process dictionary, timers, monitoring and +more. + +=== Binaries + +It uses binaries. Binaries are more efficient than lists for +representing strings because they take less memory space. Processing +performance can vary depending on the operation. Binaries are known +for generally getting a great boost if the code is compiled natively. +Please see the HiPE documentation for more details. + +=== Date header + +Because querying for the current date and time can be expensive, +Cowboy generates one `Date` header value every second, shares it +to all other processes, which then simply copy it in the response. +This allows compliance with HTTP/1.1 with no actual performance loss. + +=== Max connections + +By default the maximum number of active connections is set to a +generally accepted big enough number. This is meant to prevent having +too many processes performing potentially heavy work and slowing +everything else down, or taking up all the memory. + +Disabling this feature, by setting the `{max_connections, infinity}` +protocol option, would give you greater performance when you are +only processing short-lived requests. diff --git a/docs/en/cowboy/2.0/guide/architecture/index.html b/docs/en/cowboy/2.0/guide/architecture/index.html new file mode 100644 index 00000000..ef816699 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/architecture/index.html @@ -0,0 +1,191 @@ +<!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"> + + <meta name="generator" content="Hugo 0.15" /> + + <title>Nine Nines: Architecture</title> + + <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'> + + <link href="/css/bootstrap.min.css" rel="stylesheet"> + <link href="/css/99s.css" 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="Keep in touch!" href="http://twitter.com/lhoguin"><img src="/img/ico_microblog.png" data-hover="/img/ico_microblog_alt.png"></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>Architecture</span></h1> + +<div class="paragraph"><p>Cowboy is a lightweight HTTP server.</p></div>
+<div class="paragraph"><p>It is built on top of Ranch. Please see the Ranch guide for more
+information.</p></div>
+<div class="sect1">
+<h2 id="_one_process_per_connection">One process per connection</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>It uses only one process per connection. The process where your
+code runs is the process controlling the socket. Using one process
+instead of two allows for lower memory usage.</p></div>
+<div class="paragraph"><p>Because there can be more than one request per connection with the
+keepalive feature of HTTP/1.1, that means the same process will be
+used to handle many requests.</p></div>
+<div class="paragraph"><p>Because of this, you are expected to make sure your process cleans
+up before terminating the handling of the current request. This may
+include cleaning up the process dictionary, timers, monitoring and
+more.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_binaries">Binaries</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>It uses binaries. Binaries are more efficient than lists for
+representing strings because they take less memory space. Processing
+performance can vary depending on the operation. Binaries are known
+for generally getting a great boost if the code is compiled natively.
+Please see the HiPE documentation for more details.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_date_header">Date header</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Because querying for the current date and time can be expensive,
+Cowboy generates one <code>Date</code> header value every second, shares it
+to all other processes, which then simply copy it in the response.
+This allows compliance with HTTP/1.1 with no actual performance loss.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_max_connections">Max connections</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>By default the maximum number of active connections is set to a
+generally accepted big enough number. This is meant to prevent having
+too many processes performing potentially heavy work and slowing
+everything else down, or taking up all the memory.</p></div>
+<div class="paragraph"><p>Disabling this feature, by setting the <code>{max_connections, infinity}</code>
+protocol option, would give you greater performance when you are
+only processing short-lived requests.</p></div>
+</div>
+</div>
+ + + +</div> + +<div class="span3 sidecol"> + + +<h3> + Cowboy + 2.0 + + User Guide +</h3> + +<ul> + + <li><a href="/docs/en/cowboy/2.0/guide">User Guide</a></li> + + + <li><a href="/docs/en/cowboy/2.0/manual">Function Reference</a></li> + + +</ul> + +<h4 id="docs-nav">Navigation</h4> + +<h4>Version select</h4> +<ul> + + + + <li><a href="/docs/en/cowboy/1.0/guide">1.0</a></li> + + <li><a href="/docs/en/cowboy/2.0/guide">2.0</a></li> + +</ul> + +</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 © Loïc Hoguin 2012-2016</p> + </div> + </div> + </div> + </footer> + + + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> + <script src="/js/bootstrap-carousel.js"></script> + <script src="/js/bootstrap-dropdown.js"></script> + <script src="/js/custom.js"></script> + </body> +</html> + + diff --git a/docs/en/cowboy/2.0/guide/broken_clients.asciidoc b/docs/en/cowboy/2.0/guide/broken_clients.asciidoc new file mode 100644 index 00000000..17bb892f --- /dev/null +++ b/docs/en/cowboy/2.0/guide/broken_clients.asciidoc @@ -0,0 +1,61 @@ +[[broken_clients]] +== Dealing with broken clients + +There exists a very large number of implementations for the +HTTP protocol. Most widely used clients, like browsers, +follow the standard quite well, but others may not. In +particular custom enterprise clients tend to be very badly +written. + +Cowboy tries to follow the standard as much as possible, +but is not trying to handle every possible special cases. +Instead Cowboy focuses on the cases reported in the wild, +on the public Web. + +That means clients that ignore the HTTP standard completely +may fail to understand Cowboy's responses. There are of +course workarounds. This chapter aims to cover them. + +=== Lowercase headers + +Cowboy converts all headers it receives to lowercase, and +similarly sends back headers all in lowercase. Some broken +HTTP clients have issues with that. + +A simple way to solve this is to create an `onresponse` hook +that will format the header names with the expected case. + +[source,erlang] +---- +capitalize_hook(Status, Headers, Body, Req) -> + Headers2 = [{cowboy_bstr:capitalize_token(N), V} + || {N, V} <- Headers], + cowboy_req:reply(Status, Headers2, Body, Req). +---- + +Note that HTTP/2 clients do not have that particular issue +because the specification explicitly says all headers are +lowercase, unlike HTTP which allows any case but treats +them as case insensitive. + +=== Camel-case headers + +Sometimes it is desirable to keep the actual case used by +clients, for example when acting as a proxy between two broken +implementations. There is no easy solution for this other than +forking the project and editing the `cowboy_protocol` file +directly. + +=== Chunked transfer-encoding + +Sometimes an HTTP client advertises itself as HTTP/1.1 but +does not support chunked transfer-encoding. This is invalid +behavior, as HTTP/1.1 clients are required to support it. + +A simple workaround exists in these cases. By changing the +Req object response state to `waiting_stream`, Cowboy will +understand that it must use the identity transfer-encoding +when replying, just like if it was an HTTP/1.0 client. + +[source,erlang] +Req2 = cowboy_req:set(resp_state, waiting_stream). diff --git a/docs/en/cowboy/2.0/guide/broken_clients/index.html b/docs/en/cowboy/2.0/guide/broken_clients/index.html new file mode 100644 index 00000000..049ee878 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/broken_clients/index.html @@ -0,0 +1,205 @@ +<!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"> + + <meta name="generator" content="Hugo 0.15" /> + + <title>Nine Nines: Dealing with broken clients</title> + + <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'> + + <link href="/css/bootstrap.min.css" rel="stylesheet"> + <link href="/css/99s.css" 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="Keep in touch!" href="http://twitter.com/lhoguin"><img src="/img/ico_microblog.png" data-hover="/img/ico_microblog_alt.png"></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>Dealing with broken clients</span></h1> + +<div class="paragraph"><p>There exists a very large number of implementations for the
+HTTP protocol. Most widely used clients, like browsers,
+follow the standard quite well, but others may not. In
+particular custom enterprise clients tend to be very badly
+written.</p></div>
+<div class="paragraph"><p>Cowboy tries to follow the standard as much as possible,
+but is not trying to handle every possible special cases.
+Instead Cowboy focuses on the cases reported in the wild,
+on the public Web.</p></div>
+<div class="paragraph"><p>That means clients that ignore the HTTP standard completely
+may fail to understand Cowboy’s responses. There are of
+course workarounds. This chapter aims to cover them.</p></div>
+<div class="sect1">
+<h2 id="_lowercase_headers">Lowercase headers</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Cowboy converts all headers it receives to lowercase, and
+similarly sends back headers all in lowercase. Some broken
+HTTP clients have issues with that.</p></div>
+<div class="paragraph"><p>A simple way to solve this is to create an <code>onresponse</code> hook
+that will format the header names with the expected case.</p></div>
+<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">capitalize_hook</span></span>(<span style="color: #009900">Status</span>, <span style="color: #009900">Headers</span>, <span style="color: #009900">Body</span>, <span style="color: #009900">Req</span>) <span style="color: #990000">-></span>
+ <span style="color: #009900">Headers2</span> <span style="color: #990000">=</span> [{<span style="font-weight: bold"><span style="color: #000000">cowboy_bstr:capitalize_token</span></span>(<span style="color: #009900">N</span>), <span style="color: #009900">V</span>}
+ || {<span style="color: #009900">N</span>, <span style="color: #009900">V</span>} <span style="color: #990000"><-</span> <span style="color: #009900">Headers</span>],
+ <span style="font-weight: bold"><span style="color: #000000">cowboy_req:reply</span></span>(<span style="color: #009900">Status</span>, <span style="color: #009900">Headers2</span>, <span style="color: #009900">Body</span>, <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Note that HTTP/2 clients do not have that particular issue
+because the specification explicitly says all headers are
+lowercase, unlike HTTP which allows any case but treats
+them as case insensitive.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_camel_case_headers">Camel-case headers</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Sometimes it is desirable to keep the actual case used by
+clients, for example when acting as a proxy between two broken
+implementations. There is no easy solution for this other than
+forking the project and editing the <code>cowboy_protocol</code> file
+directly.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_chunked_transfer_encoding">Chunked transfer-encoding</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Sometimes an HTTP client advertises itself as HTTP/1.1 but
+does not support chunked transfer-encoding. This is invalid
+behavior, as HTTP/1.1 clients are required to support it.</p></div>
+<div class="paragraph"><p>A simple workaround exists in these cases. By changing the
+Req object response state to <code>waiting_stream</code>, Cowboy will
+understand that it must use the identity transfer-encoding
+when replying, just like if it was an HTTP/1.0 client.</p></div>
+<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="color: #009900">Req2</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:set</span></span>(<span style="color: #FF6600">resp_state</span>, <span style="color: #FF6600">waiting_stream</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+</div>
+</div>
+ + + +</div> + +<div class="span3 sidecol"> + + +<h3> + Cowboy + 2.0 + + User Guide +</h3> + +<ul> + + <li><a href="/docs/en/cowboy/2.0/guide">User Guide</a></li> + + + <li><a href="/docs/en/cowboy/2.0/manual">Function Reference</a></li> + + +</ul> + +<h4 id="docs-nav">Navigation</h4> + +<h4>Version select</h4> +<ul> + + + + <li><a href="/docs/en/cowboy/1.0/guide">1.0</a></li> + + <li><a href="/docs/en/cowboy/2.0/guide">2.0</a></li> + +</ul> + +</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 © Loïc Hoguin 2012-2016</p> + </div> + </div> + </div> + </footer> + + + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> + <script src="/js/bootstrap-carousel.js"></script> + <script src="/js/bootstrap-dropdown.js"></script> + <script src="/js/custom.js"></script> + </body> +</html> + + diff --git a/docs/en/cowboy/2.0/guide/constraints.asciidoc b/docs/en/cowboy/2.0/guide/constraints.asciidoc new file mode 100644 index 00000000..0ae01d59 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/constraints.asciidoc @@ -0,0 +1,54 @@ +[[constraints]] +== Constraints + +Cowboy provides an optional constraints based validation feature +when interacting with user input. + +Constraints are first used during routing. The router uses +constraints to more accurately match bound values, allowing +to create routes where a segment is an integer for example, +and rejecting the others. + +Constraints are also used when performing a match operation +on input data, like the query string or cookies. There, a +default value can also be provided for optional values. + +Finally, constraints can be used to not only validate input, +but also convert said input into proper Erlang terms, all in +one step. + +=== Structure + +Constraints are provided as a list of fields and for each +field a list of constraints for that field can be provided. + +Fields are either the name of the field; the name and +one or more constraints; or the name, one or more constraints +and a default value. + +When no default value is provided then the field is required. +Otherwise the default value is used. + +All constraints for a field will be used to match its value +in the order they are given. If the value is modified by a +constraint, the next constraint receives the updated value. + +=== Built-in constraints + +[cols="<,<",options="header"] +|=== +| Constraint | Description +| int | Convert binary value to integer. +| nonempty | Ensures the binary value is non-empty. +|=== + +=== Custom constraint + +In addition to the predefined constraints, Cowboy will accept +a fun. This fun must accept one argument and return one of +`true`, `{true, NewValue}` or `false`. The result indicates +whether the value matches the constraint, and if it does it +can optionally be modified. This allows converting the value +to a more appropriate Erlang term. + +Note that constraint functions SHOULD be pure and MUST NOT crash. diff --git a/docs/en/cowboy/2.0/guide/constraints/index.html b/docs/en/cowboy/2.0/guide/constraints/index.html new file mode 100644 index 00000000..f9c072b6 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/constraints/index.html @@ -0,0 +1,211 @@ +<!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"> + + <meta name="generator" content="Hugo 0.15" /> + + <title>Nine Nines: Constraints</title> + + <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'> + + <link href="/css/bootstrap.min.css" rel="stylesheet"> + <link href="/css/99s.css" 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="Keep in touch!" href="http://twitter.com/lhoguin"><img src="/img/ico_microblog.png" data-hover="/img/ico_microblog_alt.png"></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>Constraints</span></h1> + +<div class="paragraph"><p>Cowboy provides an optional constraints based validation feature
+when interacting with user input.</p></div>
+<div class="paragraph"><p>Constraints are first used during routing. The router uses
+constraints to more accurately match bound values, allowing
+to create routes where a segment is an integer for example,
+and rejecting the others.</p></div>
+<div class="paragraph"><p>Constraints are also used when performing a match operation
+on input data, like the query string or cookies. There, a
+default value can also be provided for optional values.</p></div>
+<div class="paragraph"><p>Finally, constraints can be used to not only validate input,
+but also convert said input into proper Erlang terms, all in
+one step.</p></div>
+<div class="sect1">
+<h2 id="_structure">Structure</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Constraints are provided as a list of fields and for each
+field a list of constraints for that field can be provided.</p></div>
+<div class="paragraph"><p>Fields are either the name of the field; the name and
+one or more constraints; or the name, one or more constraints
+and a default value.</p></div>
+<div class="paragraph"><p>When no default value is provided then the field is required.
+Otherwise the default value is used.</p></div>
+<div class="paragraph"><p>All constraints for a field will be used to match its value
+in the order they are given. If the value is modified by a
+constraint, the next constraint receives the updated value.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_built_in_constraints">Built-in constraints</h2>
+<div class="sectionbody">
+<div class="tableblock">
+<table rules="all"
+width="100%"
+frame="border"
+cellspacing="0" cellpadding="4">
+<col width="50%" />
+<col width="50%" />
+<thead>
+<tr>
+<th align="left" valign="top"> Constraint </th>
+<th align="left" valign="top"> Description</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td align="left" valign="top"><p class="table">int</p></td>
+<td align="left" valign="top"><p class="table">Convert binary value to integer.</p></td>
+</tr>
+<tr>
+<td align="left" valign="top"><p class="table">nonempty</p></td>
+<td align="left" valign="top"><p class="table">Ensures the binary value is non-empty.</p></td>
+</tr>
+</tbody>
+</table>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_custom_constraint">Custom constraint</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>In addition to the predefined constraints, Cowboy will accept
+a fun. This fun must accept one argument and return one of
+<code>true</code>, <code>{true, NewValue}</code> or <code>false</code>. The result indicates
+whether the value matches the constraint, and if it does it
+can optionally be modified. This allows converting the value
+to a more appropriate Erlang term.</p></div>
+<div class="paragraph"><p>Note that constraint functions SHOULD be pure and MUST NOT crash.</p></div>
+</div>
+</div>
+ + + +</div> + +<div class="span3 sidecol"> + + +<h3> + Cowboy + 2.0 + + User Guide +</h3> + +<ul> + + <li><a href="/docs/en/cowboy/2.0/guide">User Guide</a></li> + + + <li><a href="/docs/en/cowboy/2.0/manual">Function Reference</a></li> + + +</ul> + +<h4 id="docs-nav">Navigation</h4> + +<h4>Version select</h4> +<ul> + + + + <li><a href="/docs/en/cowboy/1.0/guide">1.0</a></li> + + <li><a href="/docs/en/cowboy/2.0/guide">2.0</a></li> + +</ul> + +</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 © Loïc Hoguin 2012-2016</p> + </div> + </div> + </div> + </footer> + + + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> + <script src="/js/bootstrap-carousel.js"></script> + <script src="/js/bootstrap-dropdown.js"></script> + <script src="/js/custom.js"></script> + </body> +</html> + + diff --git a/docs/en/cowboy/2.0/guide/cookies.asciidoc b/docs/en/cowboy/2.0/guide/cookies.asciidoc new file mode 100644 index 00000000..6068db37 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/cookies.asciidoc @@ -0,0 +1,163 @@ +[[cookies]] +== Using cookies + +Cookies are a mechanism allowing applications to maintain +state on top of the stateless HTTP protocol. + +Cowboy provides facilities for handling cookies. It is highly +recommended to use them instead of writing your own, as the +implementation of cookies can vary greatly between clients. + +Cookies are stored client-side and sent with every subsequent +request that matches the domain and path for which they were +stored, including requests for static files. For this reason +they can incur a cost which must be taken in consideration. + +Also consider that, regardless of the options used, cookies +are not to be trusted. They may be read and modified by any +program on the user's computer, but also by proxies. You +should always validate cookie values before using them. Do +not store any sensitive information in cookies either. + +When explicitly setting the domain, the cookie will be sent +for the domain and all subdomains from that domain. Otherwise +the current domain will be used. The same is true for the +path. + +When the server sets cookies, they will only be available +for requests that are sent after the client receives the +response. + +Cookies are sent in HTTP headers, therefore they must have +text values. It is your responsibility to encode any other +data type. Also note that cookie names are de facto case +sensitive. + +Cookies can be set for the client session (which generally +means until the browser is closed), or it can be set for +a number of seconds. Once it expires, or when the server +says the cookie must exist for up to 0 seconds, the cookie +is deleted by the client. To avoid this while the user +is browsing your site, you should set the cookie for +every request, essentially resetting the expiration time. + +Cookies can be restricted to secure channels. This typically +means that such a cookie will only be sent over HTTPS, +and that it will only be available by client-side scripts +that run from HTTPS webpages. + +Finally, cookies can be restricted to HTTP and HTTPS requests, +essentially disabling their access from client-side scripts. + +=== Setting cookies + +By default, cookies you set are defined for the session. + +[source,erlang] +SessionID = generate_session_id(), +Req2 = cowboy_req:set_resp_cookie(<<"sessionid">>, SessionID, [], Req). + +You can also make them expire at a specific point in the +future. + +[source,erlang] +---- +SessionID = generate_session_id(), +Req2 = cowboy_req:set_resp_cookie(<<"sessionid">>, SessionID, [ + {max_age, 3600} +], Req). +---- + +You can delete cookies that have already been set. The value +is ignored. + +[source,erlang] +---- +Req2 = cowboy_req:set_resp_cookie(<<"sessionid">>, <<>>, [ + {max_age, 0} +], Req). +---- + +You can restrict them to a specific domain and path. +For example, the following cookie will be set for the domain +`my.example.org` and all its subdomains, but only on the path +`/account` and all its subdirectories. + +[source,erlang] +---- +Req2 = cowboy_req:set_resp_cookie(<<"inaccount">>, <<"1">>, [ + {domain, "my.example.org"}, + {path, "/account"} +], Req). +---- + +You can restrict the cookie to secure channels, typically HTTPS. + +[source,erlang] +---- +SessionID = generate_session_id(), +Req2 = cowboy_req:set_resp_cookie(<<"sessionid">>, SessionID, [ + {secure, true} +], Req). +---- + +You can restrict the cookie to client-server communication +only. Such a cookie will not be available to client-side scripts. + +[source,erlang] +---- +SessionID = generate_session_id(), +Req2 = cowboy_req:set_resp_cookie(<<"sessionid">>, SessionID, [ + {http_only, true} +], Req). +---- + +Cookies may also be set client-side, for example using +Javascript. + +=== Reading cookies + +As we said, the client sends cookies with every request. +But unlike the server, the client only sends the cookie +name and value. + +Cowboy provides two different ways to read cookies. You +can either parse them as a list of key/value pairs, or +match them into a map, optionally applying constraints +to the values or providing a default if they are missing. + +You can parse the cookies and then use standard library +functions to access individual values. + +[source,erlang] +Cookies = cowboy_req:parse_cookies(Req), +{_, Lang} = lists:keyfind(<<"lang">>, 1, Cookies). + +You can match the cookies into a map. + +[source,erlang] +#{id := ID, lang := Lang} = cowboy_req:match_cookies([id, lang], Req). + +You can use constraints to validate the values while matching +them. The following snippet will crash if the `id` cookie is +not an integer number or if the `lang` cookie is empty. Additionally +the `id` cookie value will be converted to an integer term, saving +you a conversion step. + +[source,erlang] +CookiesMap = cowboy_req:match_cookies([{id, int}, {lang, nonempty}], Req). + +Note that if two cookies share the same name, then the map value +will be a list of the two cookie values. + +Read more about xref:constraints[constraints]. + +A default value can be provided. The default will be used +if the `lang` cookie is not found. It will not be used if +the cookie is found but has an empty value. + +[source,erlang] +#{lang := Lang} = cowboy_req:match_cookies([{lang, [], <<"en-US">>}], Req). + +If no default is provided and the value is missing, the +query string is deemed invalid and the process will crash. diff --git a/docs/en/cowboy/2.0/guide/cookies/index.html b/docs/en/cowboy/2.0/guide/cookies/index.html new file mode 100644 index 00000000..4aea8eb0 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/cookies/index.html @@ -0,0 +1,303 @@ +<!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"> + + <meta name="generator" content="Hugo 0.15" /> + + <title>Nine Nines: Using cookies</title> + + <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'> + + <link href="/css/bootstrap.min.css" rel="stylesheet"> + <link href="/css/99s.css" 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="Keep in touch!" href="http://twitter.com/lhoguin"><img src="/img/ico_microblog.png" data-hover="/img/ico_microblog_alt.png"></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>Using cookies</span></h1> + +<div class="paragraph"><p>Cookies are a mechanism allowing applications to maintain
+state on top of the stateless HTTP protocol.</p></div>
+<div class="paragraph"><p>Cowboy provides facilities for handling cookies. It is highly
+recommended to use them instead of writing your own, as the
+implementation of cookies can vary greatly between clients.</p></div>
+<div class="paragraph"><p>Cookies are stored client-side and sent with every subsequent
+request that matches the domain and path for which they were
+stored, including requests for static files. For this reason
+they can incur a cost which must be taken in consideration.</p></div>
+<div class="paragraph"><p>Also consider that, regardless of the options used, cookies
+are not to be trusted. They may be read and modified by any
+program on the user’s computer, but also by proxies. You
+should always validate cookie values before using them. Do
+not store any sensitive information in cookies either.</p></div>
+<div class="paragraph"><p>When explicitly setting the domain, the cookie will be sent
+for the domain and all subdomains from that domain. Otherwise
+the current domain will be used. The same is true for the
+path.</p></div>
+<div class="paragraph"><p>When the server sets cookies, they will only be available
+for requests that are sent after the client receives the
+response.</p></div>
+<div class="paragraph"><p>Cookies are sent in HTTP headers, therefore they must have
+text values. It is your responsibility to encode any other
+data type. Also note that cookie names are de facto case
+sensitive.</p></div>
+<div class="paragraph"><p>Cookies can be set for the client session (which generally
+means until the browser is closed), or it can be set for
+a number of seconds. Once it expires, or when the server
+says the cookie must exist for up to 0 seconds, the cookie
+is deleted by the client. To avoid this while the user
+is browsing your site, you should set the cookie for
+every request, essentially resetting the expiration time.</p></div>
+<div class="paragraph"><p>Cookies can be restricted to secure channels. This typically
+means that such a cookie will only be sent over HTTPS,
+and that it will only be available by client-side scripts
+that run from HTTPS webpages.</p></div>
+<div class="paragraph"><p>Finally, cookies can be restricted to HTTP and HTTPS requests,
+essentially disabling their access from client-side scripts.</p></div>
+<div class="sect1">
+<h2 id="_setting_cookies">Setting cookies</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>By default, cookies you set are defined for the session.</p></div>
+<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="color: #009900">SessionID</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">generate_session_id</span></span>(),
+<span style="color: #009900">Req2</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:set_resp_cookie</span></span>(<span style="color: #990000"><<</span><span style="color: #FF0000">"sessionid"</span><span style="color: #990000">>></span>, <span style="color: #009900">SessionID</span>, [], <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>You can also make them expire at a specific point in the
+future.</p></div>
+<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="color: #009900">SessionID</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">generate_session_id</span></span>(),
+<span style="color: #009900">Req2</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:set_resp_cookie</span></span>(<span style="color: #990000"><<</span><span style="color: #FF0000">"sessionid"</span><span style="color: #990000">>></span>, <span style="color: #009900">SessionID</span>, [
+ {<span style="color: #FF6600">max_age</span>, <span style="color: #993399">3600</span>}
+], <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>You can delete cookies that have already been set. The value
+is ignored.</p></div>
+<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="color: #009900">Req2</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:set_resp_cookie</span></span>(<span style="color: #990000"><<</span><span style="color: #FF0000">"sessionid"</span><span style="color: #990000">>></span>, <span style="color: #990000"><<>></span>, [
+ {<span style="color: #FF6600">max_age</span>, <span style="color: #993399">0</span>}
+], <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>You can restrict them to a specific domain and path.
+For example, the following cookie will be set for the domain
+<code>my.example.org</code> and all its subdomains, but only on the path
+<code>/account</code> and all its subdirectories.</p></div>
+<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="color: #009900">Req2</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:set_resp_cookie</span></span>(<span style="color: #990000"><<</span><span style="color: #FF0000">"inaccount"</span><span style="color: #990000">>></span>, <span style="color: #990000"><<</span><span style="color: #FF0000">"1"</span><span style="color: #990000">>></span>, [
+ {<span style="color: #FF6600">domain</span>, <span style="color: #FF0000">"my.example.org"</span>},
+ {<span style="color: #FF6600">path</span>, <span style="color: #FF0000">"/account"</span>}
+], <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>You can restrict the cookie to secure channels, typically HTTPS.</p></div>
+<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="color: #009900">SessionID</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">generate_session_id</span></span>(),
+<span style="color: #009900">Req2</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:set_resp_cookie</span></span>(<span style="color: #990000"><<</span><span style="color: #FF0000">"sessionid"</span><span style="color: #990000">>></span>, <span style="color: #009900">SessionID</span>, [
+ {<span style="color: #FF6600">secure</span>, <span style="color: #000080">true</span>}
+], <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>You can restrict the cookie to client-server communication
+only. Such a cookie will not be available to client-side scripts.</p></div>
+<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="color: #009900">SessionID</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">generate_session_id</span></span>(),
+<span style="color: #009900">Req2</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:set_resp_cookie</span></span>(<span style="color: #990000"><<</span><span style="color: #FF0000">"sessionid"</span><span style="color: #990000">>></span>, <span style="color: #009900">SessionID</span>, [
+ {<span style="color: #FF6600">http_only</span>, <span style="color: #000080">true</span>}
+], <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Cookies may also be set client-side, for example using
+Javascript.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_reading_cookies">Reading cookies</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>As we said, the client sends cookies with every request.
+But unlike the server, the client only sends the cookie
+name and value.</p></div>
+<div class="paragraph"><p>Cowboy provides two different ways to read cookies. You
+can either parse them as a list of key/value pairs, or
+match them into a map, optionally applying constraints
+to the values or providing a default if they are missing.</p></div>
+<div class="paragraph"><p>You can parse the cookies and then use standard library
+functions to access individual values.</p></div>
+<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="color: #009900">Cookies</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:parse_cookies</span></span>(<span style="color: #009900">Req</span>),
+{<span style="color: #990000">_</span>, <span style="color: #009900">Lang</span>} <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">lists:keyfind</span></span>(<span style="color: #990000"><<</span><span style="color: #FF0000">"lang"</span><span style="color: #990000">>></span>, <span style="color: #993399">1</span>, <span style="color: #009900">Cookies</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>You can match the cookies into a map.</p></div>
+<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="color: #FF6600">id</span> <span style="color: #990000">:=</span> <span style="color: #009900">ID</span>, <span style="color: #FF6600">lang</span> <span style="color: #990000">:=</span> <span style="color: #009900">Lang</span>} <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:match_cookies</span></span>([<span style="color: #FF6600">id</span>, <span style="color: #FF6600">lang</span>], <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>You can use constraints to validate the values while matching
+them. The following snippet will crash if the <code>id</code> cookie is
+not an integer number or if the <code>lang</code> cookie is empty. Additionally
+the <code>id</code> cookie value will be converted to an integer term, saving
+you a conversion step.</p></div>
+<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="color: #009900">CookiesMap</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:match_cookies</span></span>([{<span style="color: #FF6600">id</span>, <span style="color: #FF6600">int</span>}, {<span style="color: #FF6600">lang</span>, <span style="color: #FF6600">nonempty</span>}], <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Note that if two cookies share the same name, then the map value
+will be a list of the two cookie values.</p></div>
+<div class="paragraph"><p>Read more about <a href="../constraints">constraints</a>.</p></div>
+<div class="paragraph"><p>A default value can be provided. The default will be used
+if the <code>lang</code> cookie is not found. It will not be used if
+the cookie is found but has an empty value.</p></div>
+<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="color: #FF6600">lang</span> <span style="color: #990000">:=</span> <span style="color: #009900">Lang</span>} <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:match_cookies</span></span>([{<span style="color: #FF6600">lang</span>, [], <span style="color: #990000"><<</span><span style="color: #FF0000">"en-US"</span><span style="color: #990000">>></span>}], <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>If no default is provided and the value is missing, the
+query string is deemed invalid and the process will crash.</p></div>
+</div>
+</div>
+ + + +</div> + +<div class="span3 sidecol"> + + +<h3> + Cowboy + 2.0 + + User Guide +</h3> + +<ul> + + <li><a href="/docs/en/cowboy/2.0/guide">User Guide</a></li> + + + <li><a href="/docs/en/cowboy/2.0/manual">Function Reference</a></li> + + +</ul> + +<h4 id="docs-nav">Navigation</h4> + +<h4>Version select</h4> +<ul> + + + + <li><a href="/docs/en/cowboy/1.0/guide">1.0</a></li> + + <li><a href="/docs/en/cowboy/2.0/guide">2.0</a></li> + +</ul> + +</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 © Loïc Hoguin 2012-2016</p> + </div> + </div> + </div> + </footer> + + + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> + <script src="/js/bootstrap-carousel.js"></script> + <script src="/js/bootstrap-dropdown.js"></script> + <script src="/js/custom.js"></script> + </body> +</html> + + diff --git a/docs/en/cowboy/2.0/guide/erlang_beginners.asciidoc b/docs/en/cowboy/2.0/guide/erlang_beginners.asciidoc new file mode 100644 index 00000000..b9a6c655 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/erlang_beginners.asciidoc @@ -0,0 +1,36 @@ +[[erlang_beginners]] +== Erlang for beginners + +Chances are you are interested in using Cowboy, but have +no idea how to write an Erlang program. Fear not! This +chapter will help you get started. + +We recommend two books for beginners. You should read them +both at some point, as they cover Erlang from two entirely +different perspectives. + +=== Learn You Some Erlang for Great Good! + +The quickest way to get started with Erlang is by reading +a book with the funny name of http://learnyousomeerlang.com[LYSE], +as we affectionately call it. + +It will get right into the syntax and quickly answer the questions +a beginner would ask themselves, all the while showing funny +pictures and making insightful jokes. + +You can read an early version of the book online for free, +but you really should buy the much more refined paper and +ebook versions. + +=== Programming Erlang + +After writing some code, you will probably want to understand +the very concepts that make Erlang what it is today. These +are best explained by Joe Armstrong, the godfather of Erlang, +in his book http://pragprog.com/book/jaerlang2/programming-erlang[Programming Erlang]. + +Instead of going into every single details of the language, +Joe focuses on the central concepts behind Erlang, and shows +you how they can be used to write a variety of different +applications. diff --git a/docs/en/cowboy/2.0/guide/erlang_beginners/index.html b/docs/en/cowboy/2.0/guide/erlang_beginners/index.html new file mode 100644 index 00000000..4632dca9 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/erlang_beginners/index.html @@ -0,0 +1,175 @@ +<!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"> + + <meta name="generator" content="Hugo 0.15" /> + + <title>Nine Nines: Erlang for beginners</title> + + <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'> + + <link href="/css/bootstrap.min.css" rel="stylesheet"> + <link href="/css/99s.css" 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="Keep in touch!" href="http://twitter.com/lhoguin"><img src="/img/ico_microblog.png" data-hover="/img/ico_microblog_alt.png"></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>Erlang for beginners</span></h1> + +<div class="paragraph"><p>Chances are you are interested in using Cowboy, but have
+no idea how to write an Erlang program. Fear not! This
+chapter will help you get started.</p></div>
+<div class="paragraph"><p>We recommend two books for beginners. You should read them
+both at some point, as they cover Erlang from two entirely
+different perspectives.</p></div>
+<div class="sect1">
+<h2 id="_learn_you_some_erlang_for_great_good">Learn You Some Erlang for Great Good!</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>The quickest way to get started with Erlang is by reading
+a book with the funny name of <a href="http://learnyousomeerlang.com">LYSE</a>,
+as we affectionately call it.</p></div>
+<div class="paragraph"><p>It will get right into the syntax and quickly answer the questions
+a beginner would ask themselves, all the while showing funny
+pictures and making insightful jokes.</p></div>
+<div class="paragraph"><p>You can read an early version of the book online for free,
+but you really should buy the much more refined paper and
+ebook versions.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_programming_erlang">Programming Erlang</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>After writing some code, you will probably want to understand
+the very concepts that make Erlang what it is today. These
+are best explained by Joe Armstrong, the godfather of Erlang,
+in his book <a href="http://pragprog.com/book/jaerlang2/programming-erlang">Programming Erlang</a>.</p></div>
+<div class="paragraph"><p>Instead of going into every single details of the language,
+Joe focuses on the central concepts behind Erlang, and shows
+you how they can be used to write a variety of different
+applications.</p></div>
+</div>
+</div>
+ + + +</div> + +<div class="span3 sidecol"> + + +<h3> + Cowboy + 2.0 + + User Guide +</h3> + +<ul> + + <li><a href="/docs/en/cowboy/2.0/guide">User Guide</a></li> + + + <li><a href="/docs/en/cowboy/2.0/manual">Function Reference</a></li> + + +</ul> + +<h4 id="docs-nav">Navigation</h4> + +<h4>Version select</h4> +<ul> + + + + <li><a href="/docs/en/cowboy/1.0/guide">1.0</a></li> + + <li><a href="/docs/en/cowboy/2.0/guide">2.0</a></li> + +</ul> + +</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 © Loïc Hoguin 2012-2016</p> + </div> + </div> + </div> + </footer> + + + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> + <script src="/js/bootstrap-carousel.js"></script> + <script src="/js/bootstrap-dropdown.js"></script> + <script src="/js/custom.js"></script> + </body> +</html> + + diff --git a/docs/en/cowboy/2.0/guide/erlang_web.asciidoc b/docs/en/cowboy/2.0/guide/erlang_web.asciidoc new file mode 100644 index 00000000..702e0437 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/erlang_web.asciidoc @@ -0,0 +1,176 @@ +[[erlang_web]] +== Erlang and the Web + +=== The Web is concurrent + +When you access a website there is little concurrency +involved. A few connections are opened and requests +are sent through these connections. Then the web page +is displayed on your screen. Your browser will only +open up to 4 or 8 connections to the server, depending +on your settings. This isn't much. + +But think about it. You are not the only one accessing +the server at the same time. There can be hundreds, if +not thousands, if not millions of connections to the +same server at the same time. + +Even today a lot of systems used in production haven't +solved the C10K problem (ten thousand concurrent connections). +And the ones who did are trying hard to get to the next +step, C100K, and are pretty far from it. + +Erlang meanwhile has no problem handling millions of +connections. At the time of writing there are application +servers written in Erlang that can handle more than two +million connections on a single server in a real production +application, with spare memory and CPU! + +The Web is concurrent, and Erlang is a language designed +for concurrency, so it is a perfect match. + +Of course, various platforms need to scale beyond a few +million connections. This is where Erlang's built-in +distribution mechanisms come in. If one server isn't +enough, add more! Erlang allows you to use the same code +for talking to local processes or to processes in other +parts of your cluster, which means you can scale very +quickly if the need arises. + +The Web has large userbases, and the Erlang platform was +designed to work in a distributed setting, so it is a +perfect match. + +Or is it? Surely you can find solutions to handle that many +concurrent connections with your favorite language... But all +these solutions will break down in the next few years. Why? +Firstly because servers don't get any more powerful, they +instead get a lot more cores and memory. This is only useful +if your application can use them properly, and Erlang is +light-years away from anything else in that area. Secondly, +today your computer and your phone are online, tomorrow your +watch, goggles, bike, car, fridge and tons of other devices +will also connect to various applications on the Internet. + +Only Erlang is prepared to deal with what's coming. + +=== The Web is soft real time + +What does soft real time mean, you ask? It means we want the +operations done as quickly as possible, and in the case of +web applications, it means we want the data propagated fast. + +In comparison, hard real time has a similar meaning, but also +has a hard time constraint, for example an operation needs to +be done in under N milliseconds otherwise the system fails +entirely. + +Users aren't that needy yet, they just want to get access +to their content in a reasonable delay, and they want the +actions they make to register at most a few seconds after +they submitted them, otherwise they'll start worrying about +whether it successfully went through. + +The Web is soft real time because taking longer to perform an +operation would be seen as bad quality of service. + +Erlang is a soft real time system. It will always run +processes fairly, a little at a time, switching to another +process after a while and preventing a single process to +steal resources from all others. This means that Erlang +can guarantee stable low latency of operations. + +Erlang provides the guarantees that the soft real time Web +requires. + +=== The Web is asynchronous + +Long ago, the Web was synchronous because HTTP was synchronous. +You fired a request, and then waited for a response. Not anymore. +It all began when XmlHttpRequest started being used. It allowed +the client to perform asynchronous calls to the server. + +Then Websocket appeared and allowed both the server and the client +to send data to the other endpoint completely asynchronously. The +data is contained within frames and no response is necessary. + +Erlang processes work the same. They send each other data contained +within messages and then continue running without needing a response. +They tend to spend most of their time inactive, waiting for a new +message, and the Erlang VM happily activate them when one is received. + +It is therefore quite easy to imagine Erlang being good at receiving +Websocket frames, which may come in at unpredictable times, pass the +data to the responsible processes which are always ready waiting for +new messages, and perform the operations required by only activating +the required parts of the system. + +The more recent Web technologies, like Websocket of course, but also +HTTP/2.0, are all fully asynchronous protocols. The concept +of requests and responses is retained of course, but anything could +be sent in between, by both the client or the browser, and the +responses could also be received in a completely different order. + +Erlang is by nature asynchronous and really good at it thanks to the +great engineering that has been done in the VM over the years. It's +only natural that it's so good at dealing with the asynchronous Web. + +=== The Web is omnipresent + +The Web has taken a very important part of our lives. We're +connected at all times, when we're on our phone, using our computer, +passing time using a tablet while in the bathroom... And this +isn't going to slow down, every single device at home or on us +will be connected. + +All these devices are always connected. And with the number of +alternatives to give you access to the content you seek, users +tend to not stick around when problems arise. Users today want +their applications to be always available and if it's having +too many issues they just move on. + +Despite this, when developers choose a product to use for building +web applications, their only concern seem to be "Is it fast?", +and they look around for synthetic benchmarks showing which one +is the fastest at sending "Hello world" with only a handful +concurrent connections. Web benchmarks haven't been representative +of reality in a long time, and are drifting further away as +time goes on. + +What developers should really ask themselves is "Can I service +all my users with no interruption?" and they'd find that they have +two choices. They can either hope for the best, or they can use +Erlang. + +Erlang is built for fault tolerance. When writing code in any other +language, you have to check all the return values and act accordingly +to avoid any unforeseen issues. If you're lucky, you won't miss +anything important. When writing Erlang code, you can just check +the success condition and ignore all errors. If an error happen, +the Erlang process crashes and is then restarted by a special +process called a supervisor. + +The Erlang developer thus has no need to fear about unhandled +errors, and can focus on handling only the errors that should +give some feedback to the user and let the system take care of +the rest. This also has the advantage of allowing him to write +a lot less code, and letting him sleep at night. + +Erlang's fault tolerance oriented design is the first piece of +what makes it the best choice for the omnipresent, always available +Web. + +The second piece is Erlang's built-in distribution. Distribution +is a key part of building a fault tolerant system, because it +allows you to handle bigger failures, like a whole server going +down, or even a data center entirely. + +Fault tolerance and distribution are important today, and will be +vital in the future of the Web. Erlang is ready. + +=== Erlang is the ideal platform for the Web + +Erlang provides all the important features that the Web requires +or will require in the near future. Erlang is a perfect match +for the Web, and it only makes sense to use it to build web +applications. diff --git a/docs/en/cowboy/2.0/guide/erlang_web/index.html b/docs/en/cowboy/2.0/guide/erlang_web/index.html new file mode 100644 index 00000000..8206392a --- /dev/null +++ b/docs/en/cowboy/2.0/guide/erlang_web/index.html @@ -0,0 +1,300 @@ +<!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"> + + <meta name="generator" content="Hugo 0.15" /> + + <title>Nine Nines: Erlang and the Web</title> + + <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'> + + <link href="/css/bootstrap.min.css" rel="stylesheet"> + <link href="/css/99s.css" 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="Keep in touch!" href="http://twitter.com/lhoguin"><img src="/img/ico_microblog.png" data-hover="/img/ico_microblog_alt.png"></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>Erlang and the Web</span></h1> + +<div class="sect1">
+<h2 id="_the_web_is_concurrent">The Web is concurrent</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>When you access a website there is little concurrency
+involved. A few connections are opened and requests
+are sent through these connections. Then the web page
+is displayed on your screen. Your browser will only
+open up to 4 or 8 connections to the server, depending
+on your settings. This isn’t much.</p></div>
+<div class="paragraph"><p>But think about it. You are not the only one accessing
+the server at the same time. There can be hundreds, if
+not thousands, if not millions of connections to the
+same server at the same time.</p></div>
+<div class="paragraph"><p>Even today a lot of systems used in production haven’t
+solved the C10K problem (ten thousand concurrent connections).
+And the ones who did are trying hard to get to the next
+step, C100K, and are pretty far from it.</p></div>
+<div class="paragraph"><p>Erlang meanwhile has no problem handling millions of
+connections. At the time of writing there are application
+servers written in Erlang that can handle more than two
+million connections on a single server in a real production
+application, with spare memory and CPU!</p></div>
+<div class="paragraph"><p>The Web is concurrent, and Erlang is a language designed
+for concurrency, so it is a perfect match.</p></div>
+<div class="paragraph"><p>Of course, various platforms need to scale beyond a few
+million connections. This is where Erlang’s built-in
+distribution mechanisms come in. If one server isn’t
+enough, add more! Erlang allows you to use the same code
+for talking to local processes or to processes in other
+parts of your cluster, which means you can scale very
+quickly if the need arises.</p></div>
+<div class="paragraph"><p>The Web has large userbases, and the Erlang platform was
+designed to work in a distributed setting, so it is a
+perfect match.</p></div>
+<div class="paragraph"><p>Or is it? Surely you can find solutions to handle that many
+concurrent connections with your favorite language… But all
+these solutions will break down in the next few years. Why?
+Firstly because servers don’t get any more powerful, they
+instead get a lot more cores and memory. This is only useful
+if your application can use them properly, and Erlang is
+light-years away from anything else in that area. Secondly,
+today your computer and your phone are online, tomorrow your
+watch, goggles, bike, car, fridge and tons of other devices
+will also connect to various applications on the Internet.</p></div>
+<div class="paragraph"><p>Only Erlang is prepared to deal with what’s coming.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_the_web_is_soft_real_time">The Web is soft real time</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>What does soft real time mean, you ask? It means we want the
+operations done as quickly as possible, and in the case of
+web applications, it means we want the data propagated fast.</p></div>
+<div class="paragraph"><p>In comparison, hard real time has a similar meaning, but also
+has a hard time constraint, for example an operation needs to
+be done in under N milliseconds otherwise the system fails
+entirely.</p></div>
+<div class="paragraph"><p>Users aren’t that needy yet, they just want to get access
+to their content in a reasonable delay, and they want the
+actions they make to register at most a few seconds after
+they submitted them, otherwise they’ll start worrying about
+whether it successfully went through.</p></div>
+<div class="paragraph"><p>The Web is soft real time because taking longer to perform an
+operation would be seen as bad quality of service.</p></div>
+<div class="paragraph"><p>Erlang is a soft real time system. It will always run
+processes fairly, a little at a time, switching to another
+process after a while and preventing a single process to
+steal resources from all others. This means that Erlang
+can guarantee stable low latency of operations.</p></div>
+<div class="paragraph"><p>Erlang provides the guarantees that the soft real time Web
+requires.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_the_web_is_asynchronous">The Web is asynchronous</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Long ago, the Web was synchronous because HTTP was synchronous.
+You fired a request, and then waited for a response. Not anymore.
+It all began when XmlHttpRequest started being used. It allowed
+the client to perform asynchronous calls to the server.</p></div>
+<div class="paragraph"><p>Then Websocket appeared and allowed both the server and the client
+to send data to the other endpoint completely asynchronously. The
+data is contained within frames and no response is necessary.</p></div>
+<div class="paragraph"><p>Erlang processes work the same. They send each other data contained
+within messages and then continue running without needing a response.
+They tend to spend most of their time inactive, waiting for a new
+message, and the Erlang VM happily activate them when one is received.</p></div>
+<div class="paragraph"><p>It is therefore quite easy to imagine Erlang being good at receiving
+Websocket frames, which may come in at unpredictable times, pass the
+data to the responsible processes which are always ready waiting for
+new messages, and perform the operations required by only activating
+the required parts of the system.</p></div>
+<div class="paragraph"><p>The more recent Web technologies, like Websocket of course, but also
+HTTP/2.0, are all fully asynchronous protocols. The concept
+of requests and responses is retained of course, but anything could
+be sent in between, by both the client or the browser, and the
+responses could also be received in a completely different order.</p></div>
+<div class="paragraph"><p>Erlang is by nature asynchronous and really good at it thanks to the
+great engineering that has been done in the VM over the years. It’s
+only natural that it’s so good at dealing with the asynchronous Web.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_the_web_is_omnipresent">The Web is omnipresent</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>The Web has taken a very important part of our lives. We’re
+connected at all times, when we’re on our phone, using our computer,
+passing time using a tablet while in the bathroom… And this
+isn’t going to slow down, every single device at home or on us
+will be connected.</p></div>
+<div class="paragraph"><p>All these devices are always connected. And with the number of
+alternatives to give you access to the content you seek, users
+tend to not stick around when problems arise. Users today want
+their applications to be always available and if it’s having
+too many issues they just move on.</p></div>
+<div class="paragraph"><p>Despite this, when developers choose a product to use for building
+web applications, their only concern seem to be "Is it fast?",
+and they look around for synthetic benchmarks showing which one
+is the fastest at sending "Hello world" with only a handful
+concurrent connections. Web benchmarks haven’t been representative
+of reality in a long time, and are drifting further away as
+time goes on.</p></div>
+<div class="paragraph"><p>What developers should really ask themselves is "Can I service
+all my users with no interruption?" and they’d find that they have
+two choices. They can either hope for the best, or they can use
+Erlang.</p></div>
+<div class="paragraph"><p>Erlang is built for fault tolerance. When writing code in any other
+language, you have to check all the return values and act accordingly
+to avoid any unforeseen issues. If you’re lucky, you won’t miss
+anything important. When writing Erlang code, you can just check
+the success condition and ignore all errors. If an error happen,
+the Erlang process crashes and is then restarted by a special
+process called a supervisor.</p></div>
+<div class="paragraph"><p>The Erlang developer thus has no need to fear about unhandled
+errors, and can focus on handling only the errors that should
+give some feedback to the user and let the system take care of
+the rest. This also has the advantage of allowing him to write
+a lot less code, and letting him sleep at night.</p></div>
+<div class="paragraph"><p>Erlang’s fault tolerance oriented design is the first piece of
+what makes it the best choice for the omnipresent, always available
+Web.</p></div>
+<div class="paragraph"><p>The second piece is Erlang’s built-in distribution. Distribution
+is a key part of building a fault tolerant system, because it
+allows you to handle bigger failures, like a whole server going
+down, or even a data center entirely.</p></div>
+<div class="paragraph"><p>Fault tolerance and distribution are important today, and will be
+vital in the future of the Web. Erlang is ready.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_erlang_is_the_ideal_platform_for_the_web">Erlang is the ideal platform for the Web</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Erlang provides all the important features that the Web requires
+or will require in the near future. Erlang is a perfect match
+for the Web, and it only makes sense to use it to build web
+applications.</p></div>
+</div>
+</div>
+ + + +</div> + +<div class="span3 sidecol"> + + +<h3> + Cowboy + 2.0 + + User Guide +</h3> + +<ul> + + <li><a href="/docs/en/cowboy/2.0/guide">User Guide</a></li> + + + <li><a href="/docs/en/cowboy/2.0/manual">Function Reference</a></li> + + +</ul> + +<h4 id="docs-nav">Navigation</h4> + +<h4>Version select</h4> +<ul> + + + + <li><a href="/docs/en/cowboy/1.0/guide">1.0</a></li> + + <li><a href="/docs/en/cowboy/2.0/guide">2.0</a></li> + +</ul> + +</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 © Loïc Hoguin 2012-2016</p> + </div> + </div> + </div> + </footer> + + + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> + <script src="/js/bootstrap-carousel.js"></script> + <script src="/js/bootstrap-dropdown.js"></script> + <script src="/js/custom.js"></script> + </body> +</html> + + diff --git a/docs/en/cowboy/2.0/guide/getting_started.asciidoc b/docs/en/cowboy/2.0/guide/getting_started.asciidoc new file mode 100644 index 00000000..679d9fe3 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/getting_started.asciidoc @@ -0,0 +1,141 @@ +[[getting_started]] +== Getting started + +Erlang is more than a language, it is also an operating system +for your applications. Erlang developers rarely write standalone +modules, they write libraries or applications, and then bundle +those into what is called a release. A release contains the +Erlang VM plus all applications required to run the node, so +it can be pushed to production directly. + +This chapter walks you through all the steps of setting up +Cowboy, writing your first application and generating your first +release. At the end of this chapter you should know everything +you need to push your first Cowboy application to production. + +=== Bootstrap + +We are going to use the https://github.com/ninenines/erlang.mk[Erlang.mk] +build system. It also offers bootstrap features allowing us to +quickly get started without having to deal with minute details. + +First, let's create the directory for our application. + +[source,bash] +$ mkdir hello_erlang +$ cd hello_erlang + +Then we need to download Erlang.mk. Either use the following +command or download it manually. + +[source,bash] +$ wget https://raw.githubusercontent.com/ninenines/erlang.mk/master/erlang.mk + +We can now bootstrap our application. Since we are going to generate +a release, we will also bootstrap it at the same time. + +[source,bash] +$ make -f erlang.mk bootstrap bootstrap-rel + +This creates a Makefile, a base application, and the release files +necessary for creating the release. We can already build and start +this release. + +[source,bash] +---- +$ make run +... +([email protected])1> +---- + +Entering the command `i().` will show the running processes, including +one called `hello_erlang_sup`. This is the supervisor for our +application. + +The release currently does nothing. In the rest of this chapter we +will add Cowboy as a dependency and write a simple "Hello world!" +handler. + +=== Cowboy setup + +Modifying the 'Makefile' allows the build system to know it needs to +fetch and compile Cowboy. To do that we simply need to add two lines +to our Makefile to make it look like this: + +[source,make] +---- +PROJECT = hello_erlang + +DEPS = cowboy +dep_cowboy_commit = master + +include erlang.mk +---- + +If you run `make run` now, Cowboy will be included in the release +and started automatically. This is not enough however, as Cowboy +doesn't do anything by default. We still need to tell Cowboy to +listen for connections. + +=== Listening for connections + +We will do this when our application starts. It's a two step process. +First we need to define and compile the dispatch list, a list of +routes that Cowboy will use to map requests to handler modules. +Then we tell Cowboy to listen for connections. + +Open the 'src/hello_erlang_app.erl' file and add the necessary +code to the `start/2` function to make it look like this: + +[source,erlang] +---- +start(_Type, _Args) -> + Dispatch = cowboy_router:compile([ + {'_', [{"/", hello_handler, []}]} + ]), + {ok, _} = cowboy:start_http(my_http_listener, 100, [{port, 8080}], + [{env, [{dispatch, Dispatch}]}] + ), + hello_erlang_sup:start_link(). +---- + +The dispatch list is explained in great details in the +xref:routing[Routing] chapter. For this tutorial we map the +path `/` to the handler module `hello_handler`. This module +doesn't exist yet, we still have to write it. + +If you build and start the release, then open http://localhost:8080 +in your browser, you will get an error because the module is missing. +Any other URL, like http://localhost:8080/test, will result in a +404 error. + +=== Handling requests + +Cowboy features different kinds of handlers, including REST +and Websocket handlers. For this tutorial we will use a plain +HTTP handler. + +First, let's generate a handler from a template. + +[source,bash] +$ make new t=cowboy_http n=hello_handler + +You can then open the 'src/hello_handler.erl' file and modify +the `init/2` function like this to send a reply. + +[source,erlang] +---- +init(Req, Opts) -> + Req2 = cowboy_req:reply(200, + [{<<"content-type">>, <<"text/plain">>}], + <<"Hello Erlang!">>, + Req), + {ok, Req2, Opts}. +---- + +What the above code does is send a `200 OK` reply, with the +`content-type` header set to `text/plain` and the response +body set to `Hello Erlang!`. + +If you run the release and open http://localhost:8080 +in your browser, you should get a nice `Hello Erlang!` displayed! diff --git a/docs/en/cowboy/2.0/guide/getting_started/index.html b/docs/en/cowboy/2.0/guide/getting_started/index.html new file mode 100644 index 00000000..065d5572 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/getting_started/index.html @@ -0,0 +1,289 @@ +<!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"> + + <meta name="generator" content="Hugo 0.15" /> + + <title>Nine Nines: Getting started</title> + + <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'> + + <link href="/css/bootstrap.min.css" rel="stylesheet"> + <link href="/css/99s.css" 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="Keep in touch!" href="http://twitter.com/lhoguin"><img src="/img/ico_microblog.png" data-hover="/img/ico_microblog_alt.png"></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>Getting started</span></h1> + +<div class="paragraph"><p>Erlang is more than a language, it is also an operating system
+for your applications. Erlang developers rarely write standalone
+modules, they write libraries or applications, and then bundle
+those into what is called a release. A release contains the
+Erlang VM plus all applications required to run the node, so
+it can be pushed to production directly.</p></div>
+<div class="paragraph"><p>This chapter walks you through all the steps of setting up
+Cowboy, writing your first application and generating your first
+release. At the end of this chapter you should know everything
+you need to push your first Cowboy application to production.</p></div>
+<div class="sect1">
+<h2 id="_bootstrap">Bootstrap</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>We are going to use the <a href="https://github.com/ninenines/erlang.mk">Erlang.mk</a>
+build system. It also offers bootstrap features allowing us to
+quickly get started without having to deal with minute details.</p></div>
+<div class="paragraph"><p>First, let’s create the directory for our application.</p></div>
+<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>$ mkdir hello_erlang
+$ cd hello_erlang</tt></pre></div></div>
+<div class="paragraph"><p>Then we need to download Erlang.mk. Either use the following
+command or download it manually.</p></div>
+<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>$ wget https<span style="color: #990000">:</span>//raw<span style="color: #990000">.</span>githubusercontent<span style="color: #990000">.</span>com/ninenines/erlang<span style="color: #990000">.</span>mk/master/erlang<span style="color: #990000">.</span>mk</tt></pre></div></div>
+<div class="paragraph"><p>We can now bootstrap our application. Since we are going to generate
+a release, we will also bootstrap it at the same time.</p></div>
+<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>$ make -f erlang<span style="color: #990000">.</span>mk bootstrap bootstrap-rel</tt></pre></div></div>
+<div class="paragraph"><p>This creates a Makefile, a base application, and the release files
+necessary for creating the release. We can already build and start
+this release.</p></div>
+<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>$ make run
+<span style="color: #990000">...</span>
+<span style="color: #990000">(</span>hello_erlang@<span style="color: #993399">127.0</span><span style="color: #990000">.</span><span style="color: #993399">0.1</span><span style="color: #990000">)</span><span style="color: #993399">1</span><span style="color: #990000">></span></tt></pre></div></div>
+<div class="paragraph"><p>Entering the command <code>i().</code> will show the running processes, including
+one called <code>hello_erlang_sup</code>. This is the supervisor for our
+application.</p></div>
+<div class="paragraph"><p>The release currently does nothing. In the rest of this chapter we
+will add Cowboy as a dependency and write a simple "Hello world!"
+handler.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_cowboy_setup">Cowboy setup</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Modifying the <em>Makefile</em> allows the build system to know it needs to
+fetch and compile Cowboy. To do that we simply need to add two lines
+to our Makefile to make it look like this:</p></div>
+<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="color: #009900">PROJECT =</span> hello_erlang
+
+<span style="color: #009900">DEPS =</span> cowboy
+<span style="color: #009900">dep_cowboy_commit =</span> master
+
+include erlang.mk</tt></pre></div></div>
+<div class="paragraph"><p>If you run <code>make run</code> now, Cowboy will be included in the release
+and started automatically. This is not enough however, as Cowboy
+doesn’t do anything by default. We still need to tell Cowboy to
+listen for connections.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_listening_for_connections">Listening for connections</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>We will do this when our application starts. It’s a two step process.
+First we need to define and compile the dispatch list, a list of
+routes that Cowboy will use to map requests to handler modules.
+Then we tell Cowboy to listen for connections.</p></div>
+<div class="paragraph"><p>Open the <em>src/hello_erlang_app.erl</em> file and add the necessary
+code to the <code>start/2</code> function to make it look like this:</p></div>
+<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">start</span></span>(<span style="color: #009900">_Type</span>, <span style="color: #009900">_Args</span>) <span style="color: #990000">-></span>
+ <span style="color: #009900">Dispatch</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_router:compile</span></span>([
+ {<span style="color: #FF6600">'_'</span>, [{<span style="color: #FF0000">"/"</span>, <span style="color: #FF6600">hello_handler</span>, []}]}
+ ]),
+ {<span style="color: #FF6600">ok</span>, <span style="color: #990000">_</span>} <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy:start_http</span></span>(<span style="color: #FF6600">my_http_listener</span>, <span style="color: #993399">100</span>, [{<span style="color: #FF6600">port</span>, <span style="color: #993399">8080</span>}],
+ [{<span style="color: #FF6600">env</span>, [{<span style="color: #FF6600">dispatch</span>, <span style="color: #009900">Dispatch</span>}]}]
+ ),
+ <span style="font-weight: bold"><span style="color: #000000">hello_erlang_sup:start_link</span></span>()<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>The dispatch list is explained in great details in the
+<a href="../routing">Routing</a> chapter. For this tutorial we map the
+path <code>/</code> to the handler module <code>hello_handler</code>. This module
+doesn’t exist yet, we still have to write it.</p></div>
+<div class="paragraph"><p>If you build and start the release, then open <a href="http://localhost:8080">http://localhost:8080</a>
+in your browser, you will get an error because the module is missing.
+Any other URL, like <a href="http://localhost:8080/test">http://localhost:8080/test</a>, will result in a
+404 error.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_handling_requests">Handling requests</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Cowboy features different kinds of handlers, including REST
+and Websocket handlers. For this tutorial we will use a plain
+HTTP handler.</p></div>
+<div class="paragraph"><p>First, let’s generate a handler from a template.</p></div>
+<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>$ make new <span style="color: #009900">t</span><span style="color: #990000">=</span>cowboy_http <span style="color: #009900">n</span><span style="color: #990000">=</span>hello_handler</tt></pre></div></div>
+<div class="paragraph"><p>You can then open the <em>src/hello_handler.erl</em> file and modify
+the <code>init/2</code> function like this to send a reply.</p></div>
+<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">init</span></span>(<span style="color: #009900">Req</span>, <span style="color: #009900">Opts</span>) <span style="color: #990000">-></span>
+ <span style="color: #009900">Req2</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:reply</span></span>(<span style="color: #993399">200</span>,
+ [{<span style="color: #990000"><<</span><span style="color: #FF0000">"content-type"</span><span style="color: #990000">>></span>, <span style="color: #990000"><<</span><span style="color: #FF0000">"text/plain"</span><span style="color: #990000">>></span>}],
+ <span style="color: #990000"><<</span><span style="color: #FF0000">"Hello Erlang!"</span><span style="color: #990000">>></span>,
+ <span style="color: #009900">Req</span>),
+ {<span style="color: #FF6600">ok</span>, <span style="color: #009900">Req2</span>, <span style="color: #009900">Opts</span>}<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>What the above code does is send a <code>200 OK</code> reply, with the
+<code>content-type</code> header set to <code>text/plain</code> and the response
+body set to <code>Hello Erlang!</code>.</p></div>
+<div class="paragraph"><p>If you run the release and open <a href="http://localhost:8080">http://localhost:8080</a>
+in your browser, you should get a nice <code>Hello Erlang!</code> displayed!</p></div>
+</div>
+</div>
+ + + +</div> + +<div class="span3 sidecol"> + + +<h3> + Cowboy + 2.0 + + User Guide +</h3> + +<ul> + + <li><a href="/docs/en/cowboy/2.0/guide">User Guide</a></li> + + + <li><a href="/docs/en/cowboy/2.0/manual">Function Reference</a></li> + + +</ul> + +<h4 id="docs-nav">Navigation</h4> + +<h4>Version select</h4> +<ul> + + + + <li><a href="/docs/en/cowboy/1.0/guide">1.0</a></li> + + <li><a href="/docs/en/cowboy/2.0/guide">2.0</a></li> + +</ul> + +</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 © Loïc Hoguin 2012-2016</p> + </div> + </div> + </div> + </footer> + + + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> + <script src="/js/bootstrap-carousel.js"></script> + <script src="/js/bootstrap-dropdown.js"></script> + <script src="/js/custom.js"></script> + </body> +</html> + + diff --git a/docs/en/cowboy/2.0/guide/handlers.asciidoc b/docs/en/cowboy/2.0/guide/handlers.asciidoc new file mode 100644 index 00000000..b6cefddc --- /dev/null +++ b/docs/en/cowboy/2.0/guide/handlers.asciidoc @@ -0,0 +1,105 @@ +[[handlers]] +== Handlers + +Handlers are Erlang modules that handle HTTP requests. + +=== Plain HTTP handlers + +The most basic handler in Cowboy implements the mandatory +`init/2` callback, manipulates the request, optionally +sends a response and then returns. + +This callback receives the xref:req[Req object] and the options +defined during the xref:routing[router configuration]. + +A handler that does nothing would look like this: + +[source,erlang] +---- +init(Req, _Opts) -> + {ok, Req, #state{}}. +---- + +Despite sending no reply, a `204 No Content` reply will be +sent to the client, as Cowboy makes sure that a reply is +sent for every request. + +We need to use the Req object for sending a reply. + +[source,erlang] +---- +init(Req, _Opts) -> + Req2 = cowboy_req:reply(200, [ + {<<"content-type">>, <<"text/plain">>} + ], <<"Hello World!">>, Req), + {ok, Req2, #state{}}. +---- + +As you can see we return a 3-tuple. `ok` means that the +handler ran successfully. The Req object is returned as +it may have been modified as is the case here: replying +returns a modified Req object that you need to return +back to Cowboy for proper operations. + +The last value of the tuple is a state that will be used +in every subsequent callbacks to this handler. Plain HTTP +handlers only have one additional callback, the optional +`terminate/3`. + +=== Other handlers + +The `init/2` callback can also be used to inform Cowboy +that this is a different kind of handler and that Cowboy +should switch to it. To do this you simply need to return +the module name of the handler type you want to switch to. + +Cowboy comes with three handler types you can switch to: +xref:rest_handlers[cowboy_rest], xref:ws_handlers[cowboy_websocket] +and xref:loop_handlers[cowboy_loop]. In addition to those you +can define your own handler types. + +Switching is simple. Instead of returning `ok`, you simply +return the name of the handler type you want to use. The +following snippet switches to a Websocket handler: + +[source,erlang] +---- +init(Req, _Opts) -> + {cowboy_websocket, Req, #state{}}. +---- + +You can also switch to your own custom handler type: + +[source,erlang] +---- +init(Req, _Opts) -> + {my_handler_type, Req, #state{}}. +---- + +How to implement a custom handler type is described in the +xref:sub_protocols[Sub protocols] chapter. + +=== Cleaning up + +All handlers coming with Cowboy allow the use of the optional +`terminate/3` callback. + +[source,erlang] +---- +terminate(_Reason, Req, State) -> + ok. +---- + +This callback is strictly reserved for any required cleanup. +You cannot send a response from this function. There is no +other return value. + +If you used the process dictionary, timers, monitors or may +be receiving messages, then you can use this function to clean +them up, as Cowboy might reuse the process for the next +keep-alive request. + +Note that while this function may be called in a Websocket +handler, it is generally not useful to do any clean up as +the process terminates immediately after calling this callback +when using Websocket. diff --git a/docs/en/cowboy/2.0/guide/handlers/index.html b/docs/en/cowboy/2.0/guide/handlers/index.html new file mode 100644 index 00000000..4d42be27 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/handlers/index.html @@ -0,0 +1,242 @@ +<!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"> + + <meta name="generator" content="Hugo 0.15" /> + + <title>Nine Nines: Handlers</title> + + <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'> + + <link href="/css/bootstrap.min.css" rel="stylesheet"> + <link href="/css/99s.css" 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="Keep in touch!" href="http://twitter.com/lhoguin"><img src="/img/ico_microblog.png" data-hover="/img/ico_microblog_alt.png"></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>Handlers</span></h1> + +<div class="paragraph"><p>Handlers are Erlang modules that handle HTTP requests.</p></div>
+<div class="sect1">
+<h2 id="_plain_http_handlers">Plain HTTP handlers</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>The most basic handler in Cowboy implements the mandatory
+<code>init/2</code> callback, manipulates the request, optionally
+sends a response and then returns.</p></div>
+<div class="paragraph"><p>This callback receives the <a href="../req">Req object</a> and the options
+defined during the <a href="../routing">router configuration</a>.</p></div>
+<div class="paragraph"><p>A handler that does nothing would look like this:</p></div>
+<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">init</span></span>(<span style="color: #009900">Req</span>, <span style="color: #009900">_Opts</span>) <span style="color: #990000">-></span>
+ {<span style="color: #FF6600">ok</span>, <span style="color: #009900">Req</span>, <span style="color: #008080">#state</span>{}}<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Despite sending no reply, a <code>204 No Content</code> reply will be
+sent to the client, as Cowboy makes sure that a reply is
+sent for every request.</p></div>
+<div class="paragraph"><p>We need to use the Req object for sending a reply.</p></div>
+<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">init</span></span>(<span style="color: #009900">Req</span>, <span style="color: #009900">_Opts</span>) <span style="color: #990000">-></span>
+ <span style="color: #009900">Req2</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:reply</span></span>(<span style="color: #993399">200</span>, [
+ {<span style="color: #990000"><<</span><span style="color: #FF0000">"content-type"</span><span style="color: #990000">>></span>, <span style="color: #990000"><<</span><span style="color: #FF0000">"text/plain"</span><span style="color: #990000">>></span>}
+ ], <span style="color: #990000"><<</span><span style="color: #FF0000">"Hello World!"</span><span style="color: #990000">>></span>, <span style="color: #009900">Req</span>),
+ {<span style="color: #FF6600">ok</span>, <span style="color: #009900">Req2</span>, <span style="color: #008080">#state</span>{}}<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>As you can see we return a 3-tuple. <code>ok</code> means that the
+handler ran successfully. The Req object is returned as
+it may have been modified as is the case here: replying
+returns a modified Req object that you need to return
+back to Cowboy for proper operations.</p></div>
+<div class="paragraph"><p>The last value of the tuple is a state that will be used
+in every subsequent callbacks to this handler. Plain HTTP
+handlers only have one additional callback, the optional
+<code>terminate/3</code>.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_other_handlers">Other handlers</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>The <code>init/2</code> callback can also be used to inform Cowboy
+that this is a different kind of handler and that Cowboy
+should switch to it. To do this you simply need to return
+the module name of the handler type you want to switch to.</p></div>
+<div class="paragraph"><p>Cowboy comes with three handler types you can switch to:
+<a href="../rest_handlers">cowboy_rest</a>, <a href="#ws_handlers">cowboy_websocket</a>
+and <a href="../loop_handlers">cowboy_loop</a>. In addition to those you
+can define your own handler types.</p></div>
+<div class="paragraph"><p>Switching is simple. Instead of returning <code>ok</code>, you simply
+return the name of the handler type you want to use. The
+following snippet switches to a Websocket handler:</p></div>
+<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">init</span></span>(<span style="color: #009900">Req</span>, <span style="color: #009900">_Opts</span>) <span style="color: #990000">-></span>
+ {<span style="color: #FF6600">cowboy_websocket</span>, <span style="color: #009900">Req</span>, <span style="color: #008080">#state</span>{}}<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>You can also switch to your own custom handler type:</p></div>
+<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">init</span></span>(<span style="color: #009900">Req</span>, <span style="color: #009900">_Opts</span>) <span style="color: #990000">-></span>
+ {<span style="color: #FF6600">my_handler_type</span>, <span style="color: #009900">Req</span>, <span style="color: #008080">#state</span>{}}<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>How to implement a custom handler type is described in the
+<a href="../sub_protocols">Sub protocols</a> chapter.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_cleaning_up">Cleaning up</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>All handlers coming with Cowboy allow the use of the optional
+<code>terminate/3</code> callback.</p></div>
+<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">terminate</span></span>(<span style="color: #009900">_Reason</span>, <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>) <span style="color: #990000">-></span>
+ <span style="color: #FF6600">ok</span><span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>This callback is strictly reserved for any required cleanup.
+You cannot send a response from this function. There is no
+other return value.</p></div>
+<div class="paragraph"><p>If you used the process dictionary, timers, monitors or may
+be receiving messages, then you can use this function to clean
+them up, as Cowboy might reuse the process for the next
+keep-alive request.</p></div>
+<div class="paragraph"><p>Note that while this function may be called in a Websocket
+handler, it is generally not useful to do any clean up as
+the process terminates immediately after calling this callback
+when using Websocket.</p></div>
+</div>
+</div>
+ + + +</div> + +<div class="span3 sidecol"> + + +<h3> + Cowboy + 2.0 + + User Guide +</h3> + +<ul> + + <li><a href="/docs/en/cowboy/2.0/guide">User Guide</a></li> + + + <li><a href="/docs/en/cowboy/2.0/manual">Function Reference</a></li> + + +</ul> + +<h4 id="docs-nav">Navigation</h4> + +<h4>Version select</h4> +<ul> + + + + <li><a href="/docs/en/cowboy/1.0/guide">1.0</a></li> + + <li><a href="/docs/en/cowboy/2.0/guide">2.0</a></li> + +</ul> + +</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 © Loïc Hoguin 2012-2016</p> + </div> + </div> + </div> + </footer> + + + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> + <script src="/js/bootstrap-carousel.js"></script> + <script src="/js/bootstrap-dropdown.js"></script> + <script src="/js/custom.js"></script> + </body> +</html> + + diff --git a/docs/en/cowboy/2.0/guide/hooks.asciidoc b/docs/en/cowboy/2.0/guide/hooks.asciidoc new file mode 100644 index 00000000..fc79f8ac --- /dev/null +++ b/docs/en/cowboy/2.0/guide/hooks.asciidoc @@ -0,0 +1,46 @@ +[[hooks]] +== Hooks + +Hooks allow the user to customize Cowboy's behavior during specific +operations. + +=== Onresponse + +The `onresponse` hook is called right before sending the response +to the socket. It can be used for the purposes of logging responses, +or for modifying the response headers or body. The best example is +providing custom error pages. + +Note that this function MUST NOT crash. Cowboy may or may not send a +reply if this function crashes. If a reply is sent, the hook MUST +explicitly provide all headers that are needed. + +You can specify the `onresponse` hook when creating the listener. + +[source,erlang] +---- +cowboy:start_http(my_http_listener, 100, + [{port, 8080}], + [ + {env, [{dispatch, Dispatch}]}, + {onresponse, fun ?MODULE:custom_404_hook/4} + ] +). +---- + +The following hook function will provide a custom body for 404 errors +when it has not been provided before, and will let Cowboy proceed with +the default response otherwise. + +[source,erlang] +---- +custom_404_hook(404, Headers, <<>>, Req) -> + Body = <<"404 Not Found.">>, + Headers2 = lists:keyreplace(<<"content-length">>, 1, Headers, + {<<"content-length">>, integer_to_list(byte_size(Body))}), + cowboy_req:reply(404, Headers2, Body, Req); +custom_404_hook(_, _, _, Req) -> + Req. +---- + +Again, make sure to always return the last request object obtained. diff --git a/docs/en/cowboy/2.0/guide/hooks/index.html b/docs/en/cowboy/2.0/guide/hooks/index.html new file mode 100644 index 00000000..31b73d25 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/hooks/index.html @@ -0,0 +1,185 @@ +<!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"> + + <meta name="generator" content="Hugo 0.15" /> + + <title>Nine Nines: Hooks</title> + + <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'> + + <link href="/css/bootstrap.min.css" rel="stylesheet"> + <link href="/css/99s.css" 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="Keep in touch!" href="http://twitter.com/lhoguin"><img src="/img/ico_microblog.png" data-hover="/img/ico_microblog_alt.png"></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>Hooks</span></h1> + +<div class="paragraph"><p>Hooks allow the user to customize Cowboy’s behavior during specific
+operations.</p></div>
+<div class="sect1">
+<h2 id="_onresponse">Onresponse</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>The <code>onresponse</code> hook is called right before sending the response
+to the socket. It can be used for the purposes of logging responses,
+or for modifying the response headers or body. The best example is
+providing custom error pages.</p></div>
+<div class="paragraph"><p>Note that this function MUST NOT crash. Cowboy may or may not send a
+reply if this function crashes. If a reply is sent, the hook MUST
+explicitly provide all headers that are needed.</p></div>
+<div class="paragraph"><p>You can specify the <code>onresponse</code> hook when creating the listener.</p></div>
+<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">cowboy:start_http</span></span>(<span style="color: #FF6600">my_http_listener</span>, <span style="color: #993399">100</span>,
+ [{<span style="color: #FF6600">port</span>, <span style="color: #993399">8080</span>}],
+ [
+ {<span style="color: #FF6600">env</span>, [{<span style="color: #FF6600">dispatch</span>, <span style="color: #009900">Dispatch</span>}]},
+ {<span style="color: #FF6600">onresponse</span>, <span style="font-weight: bold"><span style="color: #0000FF">fun</span></span> <span style="font-weight: bold"><span style="color: #000080">?MODULE</span></span><span style="color: #990000">:</span><span style="font-weight: bold"><span style="color: #000000">custom_404_hook</span></span><span style="color: #990000">/</span><span style="color: #993399">4</span>}
+ ]
+)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>The following hook function will provide a custom body for 404 errors
+when it has not been provided before, and will let Cowboy proceed with
+the default response otherwise.</p></div>
+<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">custom_404_hook</span></span>(<span style="color: #993399">404</span>, <span style="color: #009900">Headers</span>, <span style="color: #990000"><<>></span>, <span style="color: #009900">Req</span>) <span style="color: #990000">-></span>
+ <span style="color: #009900">Body</span> <span style="color: #990000">=</span> <span style="color: #990000"><<</span><span style="color: #FF0000">"404 Not Found."</span><span style="color: #990000">>></span>,
+ <span style="color: #009900">Headers2</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">lists:keyreplace</span></span>(<span style="color: #990000"><<</span><span style="color: #FF0000">"content-length"</span><span style="color: #990000">>></span>, <span style="color: #993399">1</span>, <span style="color: #009900">Headers</span>,
+ {<span style="color: #990000"><<</span><span style="color: #FF0000">"content-length"</span><span style="color: #990000">>></span>, <span style="font-weight: bold"><span style="color: #000080">integer_to_list</span></span>(<span style="font-weight: bold"><span style="color: #000080">byte_size</span></span>(<span style="color: #009900">Body</span>))}),
+ <span style="font-weight: bold"><span style="color: #000000">cowboy_req:reply</span></span>(<span style="color: #993399">404</span>, <span style="color: #009900">Headers2</span>, <span style="color: #009900">Body</span>, <span style="color: #009900">Req</span>);
+<span style="font-weight: bold"><span style="color: #000000">custom_404_hook</span></span>(<span style="color: #990000">_</span>, <span style="color: #990000">_</span>, <span style="color: #990000">_</span>, <span style="color: #009900">Req</span>) <span style="color: #990000">-></span>
+ <span style="color: #009900">Req</span><span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Again, make sure to always return the last request object obtained.</p></div>
+</div>
+</div>
+ + + +</div> + +<div class="span3 sidecol"> + + +<h3> + Cowboy + 2.0 + + User Guide +</h3> + +<ul> + + <li><a href="/docs/en/cowboy/2.0/guide">User Guide</a></li> + + + <li><a href="/docs/en/cowboy/2.0/manual">Function Reference</a></li> + + +</ul> + +<h4 id="docs-nav">Navigation</h4> + +<h4>Version select</h4> +<ul> + + + + <li><a href="/docs/en/cowboy/1.0/guide">1.0</a></li> + + <li><a href="/docs/en/cowboy/2.0/guide">2.0</a></li> + +</ul> + +</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 © Loïc Hoguin 2012-2016</p> + </div> + </div> + </div> + </footer> + + + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> + <script src="/js/bootstrap-carousel.js"></script> + <script src="/js/bootstrap-dropdown.js"></script> + <script src="/js/custom.js"></script> + </body> +</html> + + diff --git a/docs/en/cowboy/2.0/guide/http_req_resp.png b/docs/en/cowboy/2.0/guide/http_req_resp.png Binary files differnew file mode 100644 index 00000000..8c9cae99 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/http_req_resp.png diff --git a/docs/en/cowboy/2.0/guide/http_req_resp.svg b/docs/en/cowboy/2.0/guide/http_req_resp.svg new file mode 100644 index 00000000..d1e7f784 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/http_req_resp.svg @@ -0,0 +1,520 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:osb="http://www.openswatchbook.org/uri/2009/osb" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="744.09448819" + height="1052.3622047" + id="svg2" + version="1.1" + inkscape:version="0.48.4 r9939" + sodipodi:docname="http_req_resp.svg" + inkscape:export-filename="/home/essen/Dropbox/Public/drawing.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90"> + <defs + id="defs4"> + <linearGradient + id="linearGradient5265"> + <stop + style="stop-color:#69d2e7;stop-opacity:1;" + offset="0" + id="stop5267" /> + <stop + style="stop-color:#69d2e7;stop-opacity:0.58823532;" + offset="1" + id="stop5269" /> + </linearGradient> + <linearGradient + id="linearGradient5251"> + <stop + style="stop-color:#69d2e7;stop-opacity:0.78431374;" + offset="0" + id="stop5253" /> + <stop + id="stop5263" + offset="0.5" + style="stop-color:#69d2e7;stop-opacity:1;" /> + <stop + style="stop-color:#69d2e7;stop-opacity:0.39215687;" + offset="1" + id="stop5255" /> + </linearGradient> + <linearGradient + id="linearGradient5233" + osb:paint="solid"> + <stop + style="stop-color:#69d2e7;stop-opacity:1;" + offset="0" + id="stop5235" /> + </linearGradient> + </defs> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="1" + inkscape:pageshadow="2" + inkscape:zoom="1.4142136" + inkscape:cx="82.28271" + inkscape:cy="764.83183" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="false" + inkscape:window-width="2560" + inkscape:window-height="1402" + inkscape:window-x="0" + inkscape:window-y="38" + inkscape:window-maximized="1" + inkscape:snap-global="true" + showguides="true"> + <inkscape:grid + type="xygrid" + id="grid5357" + empspacing="5" + visible="true" + enabled="true" + snapvisiblegridlinesonly="true" /> + </sodipodi:namedview> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title /> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1"> + <path + inkscape:export-ydpi="89.926643" + inkscape:export-xdpi="89.926643" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:connector-curvature="0" + id="use5779" + d="M 194.29441,340.67017 369.64493,238.3853" + style="fill:none;stroke:#6d8e41;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:2, 4;stroke-dashoffset:0" /> + <path + inkscape:export-ydpi="89.926643" + inkscape:export-xdpi="89.926643" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:connector-curvature="0" + id="use5777" + d="m 178.49877,231.1517 203.00246,0.045" + style="fill:none;stroke:#6d8e41;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:1.99999999, 3.99999998;stroke-dashoffset:0" /> + <use + x="0" + y="0" + xlink:href="#g5650" + id="use5753" + transform="translate(475.11201,-117.70525)" + width="744.09448" + height="1052.3622" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <use + x="0" + y="0" + xlink:href="#use5753" + id="use5755" + transform="translate(3.984568e-6,86.977569)" + width="744.09448" + height="1052.3622" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <rect + style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:2.44279909;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5367" + width="207.05719" + height="171.55719" + x="43.721401" + y="276.1973" + rx="11.072577" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <use + x="0" + y="0" + xlink:href="#g5650" + id="use5654" + transform="translate(205.03261,-31.336292)" + width="744.09448" + height="1052.3622" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <g + id="use5660" + transform="translate(205.03261,-207.5)"> + <path + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m -57.78256,351.41962 0,52.3259" + id="path3051" + inkscape:connector-curvature="0" /> + <path + sodipodi:type="star" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="path3053" + sodipodi:sides="3" + sodipodi:cx="-222.73865" + sodipodi:cy="415.25897" + sodipodi:r1="14.849242" + sodipodi:r2="7.4246211" + sodipodi:arg1="1.5707963" + sodipodi:arg2="2.6179939" + inkscape:flatsided="true" + inkscape:rounded="0" + inkscape:randomized="0" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:transform-center-y="2.1823437" + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" /> + </g> + <use + x="0" + y="0" + xlink:href="#use5660" + id="use5662" + transform="translate(0,-86.562562)" + width="744.09448" + height="1052.3622" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <g + id="g5650"> + <path + inkscape:connector-curvature="0" + id="path5570" + d="m -57.78256,351.41962 0,52.3259" + style="fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;opacity:0.8" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576" + style="fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0;opacity:0.8" + sodipodi:type="star" /> + </g> + <use + x="0" + y="0" + xlink:href="#use5654" + id="use5656" + transform="translate(6.1542801e-7,-87.19819)" + width="744.09448" + height="1052.3622" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273" + width="104.5895" + height="36.392323" + x="-224.02068" + y="29.41218" + rx="15" /> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7" + width="104.5895" + height="36.392323" + x="-224.02068" + y="90.691978" + rx="15" /> + <rect + style="fill:#ffc48c;fill-opacity:1;fill-rule:nonzero;stroke:#d79c64;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-2" + width="104.5895" + height="36.392323" + x="-224.02068" + y="151.97169" + rx="15" /> + <rect + style="fill:#ff9f80;fill-opacity:1;fill-rule:nonzero;stroke:#d77758;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-22" + width="104.5895" + height="36.392323" + x="-224.02068" + y="213.25146" + rx="15" /> + <rect + style="fill:#f56991;fill-opacity:1;fill-rule:nonzero;stroke:#cd4169;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-8" + width="104.5895" + height="36.392323" + x="-224.02068" + y="274.53128" + rx="15" /> + <use + x="0" + y="0" + xlink:href="#rect5273-22" + id="use5355" + transform="translate(318.97592,-176.5)" + width="744.09448" + height="1052.3622" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <use + x="0" + y="0" + xlink:href="#rect5273-7" + id="use5359" + transform="translate(318.97597,32.954225)" + width="744.09448" + height="1052.3622" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <use + x="0" + y="0" + xlink:href="#use5359" + id="use5361" + transform="translate(1.630859e-6,86.769591)" + width="744.09448" + height="1052.3622" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <rect + rx="15" + y="386.37247" + x="94.955292" + height="36.392323" + width="104.5895" + id="use5363" + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" /> + <use + x="0" + y="0" + xlink:href="#use5361" + id="use5365" + transform="translate(0,88.97624)" + width="744.09448" + height="1052.3622" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="-58.692513" + y="114.39204" + id="text5371" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373" + x="-58.692513" + y="114.39204">some text</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="146.77734" + y="147.73293" + id="text5371-7" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-3" + x="146.77734" + y="147.73293">acceptor</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="146.53125" + y="233.42836" + id="text5371-74" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-5" + x="146.53125" + y="233.42836">parser</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="146.53125" + y="323.0921" + id="text5371-5" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-0" + x="146.53125" + y="323.0921">router</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="-58.692513" + y="53.112247" + id="text5371-2" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-6" + x="-58.692513" + y="53.112247">some text</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="146.53125" + y="410.38519" + id="text5371-2-3-0" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-7-3" + x="146.53125" + y="410.38519">handler</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="-362.30792" + y="63.078125" + id="text5371-2-3-0-7" + sodipodi:linespacing="125%" + transform="matrix(0,-1,1,0,0,0)" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-7-3-9" + x="-362.30792" + y="63.078125">middlewares</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="-58.692513" + y="236.95154" + id="text5371-4" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-9" + x="-58.692513" + y="236.95154">some text</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="147.00391" + y="60.912468" + id="text5371-4-0" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-2" + x="147.00391" + y="60.912468">client</tspan></text> + <use + x="0" + y="0" + xlink:href="#rect5273-7" + id="use5668" + transform="translate(589.05532,122.34788)" + width="744.09448" + height="1052.3622" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <use + x="0" + y="0" + xlink:href="#rect5273" + id="use5670" + transform="translate(589.05538,270.59134)" + width="744.09448" + height="1052.3622" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <use + x="0" + y="0" + xlink:href="#use5355" + id="use5672" + transform="translate(270.07946,350.22962)" + width="744.09448" + height="1052.3622" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <use + x="0" + y="0" + xlink:href="#text5371-4-0" + id="use5674" + transform="translate(270.29655,349.47315)" + width="744.09448" + height="1052.3622" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="417.30829" + y="236.73991" + id="text5371-9" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-57" + x="417.30829" + y="236.73991">reply</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="417.30829" + y="323.09195" + id="text5371-2-0" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-8" + x="417.30829" + y="323.09195">onresponse</tspan></text> + </g> +</svg> diff --git a/docs/en/cowboy/2.0/guide/index.html b/docs/en/cowboy/2.0/guide/index.html new file mode 100644 index 00000000..53dab6d1 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/index.html @@ -0,0 +1,326 @@ +<!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"> + + <meta name="generator" content="Hugo 0.15" /> + + <title>Nine Nines: Cowboy User Guide</title> + + <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'> + + <link href="/css/bootstrap.min.css" rel="stylesheet"> + <link href="/css/99s.css" 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="Keep in touch!" href="http://twitter.com/lhoguin"><img src="/img/ico_microblog.png" data-hover="/img/ico_microblog_alt.png"></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 User Guide</span></h1> + +<div class="sect1">
+<h2 id="_rationale">Rationale</h2>
+<div class="sectionbody">
+<div class="ulist"><ul>
+<li>
+<p>
+<a href="modern_web/">The modern Web</a>
+</p>
+</li>
+<li>
+<p>
+<a href="erlang_web/">Erlang and the Web</a>
+</p>
+</li>
+</ul></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_introduction">Introduction</h2>
+<div class="sectionbody">
+<div class="ulist"><ul>
+<li>
+<p>
+<a href="introduction/">Introduction</a>
+</p>
+</li>
+<li>
+<p>
+<a href="getting_started/">Getting started</a>
+</p>
+</li>
+<li>
+<p>
+<a href="overview/">Request overview</a>
+</p>
+</li>
+<li>
+<p>
+<a href="erlang_beginners/">Erlang for beginners</a>
+</p>
+</li>
+</ul></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_configuration">Configuration</h2>
+<div class="sectionbody">
+<div class="ulist"><ul>
+<li>
+<p>
+<a href="routing/">routing</a>
+</p>
+</li>
+<li>
+<p>
+<a href="constraints/">Constraints</a>
+</p>
+</li>
+<li>
+<p>
+<a href="static_files/">Static files</a>
+</p>
+</li>
+</ul></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_request_and_response">Request and response</h2>
+<div class="sectionbody">
+<div class="ulist"><ul>
+<li>
+<p>
+<a href="handlers/">Handlers</a>
+</p>
+</li>
+<li>
+<p>
+<a href="loop_handlers/">Loop handlers</a>
+</p>
+</li>
+<li>
+<p>
+<a href="req/">The Req object</a>
+</p>
+</li>
+<li>
+<p>
+<a href="req_body/">Reading the request body</a>
+</p>
+</li>
+<li>
+<p>
+<a href="resp/">Sending a response</a>
+</p>
+</li>
+<li>
+<p>
+<a href="cookies/">Using cookies</a>
+</p>
+</li>
+<li>
+<p>
+<a href="multipart/">Multipart</a>
+</p>
+</li>
+</ul></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_rest">REST</h2>
+<div class="sectionbody">
+<div class="ulist"><ul>
+<li>
+<p>
+<a href="rest_principles/">REST principles</a>
+</p>
+</li>
+<li>
+<p>
+<a href="rest_handlers/">Handling REST requests</a>
+</p>
+</li>
+<li>
+<p>
+<a href="rest_flowcharts/">REST flowcharts</a>
+</p>
+</li>
+<li>
+<p>
+<a href="resource_design/">Designing a resource handler</a>
+</p>
+</li>
+</ul></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_websocket">Websocket</h2>
+<div class="sectionbody">
+<div class="ulist"><ul>
+<li>
+<p>
+<a href="ws_protocol/">The Websocket protocol</a>
+</p>
+</li>
+<li>
+<p>
+<a href="ws_handlers/">Handling Websocket connections</a>
+</p>
+</li>
+</ul></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_internals">Internals</h2>
+<div class="sectionbody">
+<div class="ulist"><ul>
+<li>
+<p>
+<a href="architecture/">Architecture</a>
+</p>
+</li>
+<li>
+<p>
+<a href="broken_clients/">Dealing with broken clients</a>
+</p>
+</li>
+<li>
+<p>
+<a href="middlewares/">Middlewares</a>
+</p>
+</li>
+<li>
+<p>
+<a href="sub_protocols/">Sub protocols</a>
+</p>
+</li>
+<li>
+<p>
+<a href="hooks/">Hooks</a>
+</p>
+</li>
+</ul></div>
+</div>
+</div>
+ + + +</div> + +<div class="span3 sidecol"> + + +<h3> + Cowboy + 2.0 + + User Guide +</h3> + +<ul> + + <li><a href="/docs/en/cowboy/2.0/guide">User Guide</a></li> + + + <li><a href="/docs/en/cowboy/2.0/manual">Function Reference</a></li> + + +</ul> + +<h4 id="docs-nav">Navigation</h4> + +<h4>Version select</h4> +<ul> + + + + <li><a href="/docs/en/cowboy/1.0/guide">1.0</a></li> + + <li><a href="/docs/en/cowboy/2.0/guide">2.0</a></li> + +</ul> + +</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 © Loïc Hoguin 2012-2016</p> + </div> + </div> + </div> + </footer> + + + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> + <script src="/js/bootstrap-carousel.js"></script> + <script src="/js/bootstrap-dropdown.js"></script> + <script src="/js/custom.js"></script> + </body> +</html> + + diff --git a/docs/en/cowboy/2.0/guide/introduction.asciidoc b/docs/en/cowboy/2.0/guide/introduction.asciidoc new file mode 100644 index 00000000..9cdcbc99 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/introduction.asciidoc @@ -0,0 +1,56 @@ +[[introduction]] +== Introduction + +Cowboy is a small, fast and modular HTTP server written in Erlang. + +Cowboy aims to provide a complete HTTP stack, including its derivatives +Websocket and REST. Cowboy currently supports HTTP/1.0, HTTP/1.1, HTTP/2, +Websocket (all implemented drafts + standard) and Webmachine-based REST. + +Cowboy is a high quality project. It has a small code base, is very +efficient (both in latency and memory use) and can easily be embedded +in another application. + +Cowboy is clean Erlang code. It includes hundreds of tests and its code +is fully compliant with the Dialyzer. It is also well documented and +features both a Function Reference and a User Guide. + +=== Prerequisites + +Beginner Erlang knowledge is recommended for reading this guide. + +Knowledge of the HTTP protocol is recommended but not required, as it +will be detailed throughout the guide. + +=== Supported platforms + +Cowboy is tested and supported on Linux. + +Cowboy has been reported to work on other platforms, but we make no +guarantee that the experience will be safe and smooth. You are advised +to perform the necessary testing and security audits prior to deploying +on other platforms. + +Cowboy is developed for Erlang/OTP 17.0, 17.1.2 and 17.3. By the time +this branch gets released the target version will probably be 18.0 and +above. + +Cowboy may be compiled on other Erlang versions with small source code +modifications but there is no guarantee that it will work as expected. + +Cowboy uses the maps data type which was introduced in Erlang 17.0. + +=== Versioning + +Cowboy uses http://semver.org/[Semantic Versioning 2.0.0]. + +=== Conventions + +In the HTTP protocol, the method name is case sensitive. All standard +method names are uppercase. + +Header names are case insensitive. Cowboy converts all the request +header names to lowercase, and expects your application to provide +lowercase header names in the response. + +The same applies to any other case insensitive value. diff --git a/docs/en/cowboy/2.0/guide/introduction/index.html b/docs/en/cowboy/2.0/guide/introduction/index.html new file mode 100644 index 00000000..1a43c339 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/introduction/index.html @@ -0,0 +1,193 @@ +<!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"> + + <meta name="generator" content="Hugo 0.15" /> + + <title>Nine Nines: Introduction</title> + + <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'> + + <link href="/css/bootstrap.min.css" rel="stylesheet"> + <link href="/css/99s.css" 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="Keep in touch!" href="http://twitter.com/lhoguin"><img src="/img/ico_microblog.png" data-hover="/img/ico_microblog_alt.png"></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>Introduction</span></h1> + +<div class="paragraph"><p>Cowboy is a small, fast and modular HTTP server written in Erlang.</p></div>
+<div class="paragraph"><p>Cowboy aims to provide a complete HTTP stack, including its derivatives
+Websocket and REST. Cowboy currently supports HTTP/1.0, HTTP/1.1, HTTP/2,
+Websocket (all implemented drafts + standard) and Webmachine-based REST.</p></div>
+<div class="paragraph"><p>Cowboy is a high quality project. It has a small code base, is very
+efficient (both in latency and memory use) and can easily be embedded
+in another application.</p></div>
+<div class="paragraph"><p>Cowboy is clean Erlang code. It includes hundreds of tests and its code
+is fully compliant with the Dialyzer. It is also well documented and
+features both a Function Reference and a User Guide.</p></div>
+<div class="sect1">
+<h2 id="_prerequisites">Prerequisites</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Beginner Erlang knowledge is recommended for reading this guide.</p></div>
+<div class="paragraph"><p>Knowledge of the HTTP protocol is recommended but not required, as it
+will be detailed throughout the guide.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_supported_platforms">Supported platforms</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Cowboy is tested and supported on Linux.</p></div>
+<div class="paragraph"><p>Cowboy has been reported to work on other platforms, but we make no
+guarantee that the experience will be safe and smooth. You are advised
+to perform the necessary testing and security audits prior to deploying
+on other platforms.</p></div>
+<div class="paragraph"><p>Cowboy is developed for Erlang/OTP 17.0, 17.1.2 and 17.3. By the time
+this branch gets released the target version will probably be 18.0 and
+above.</p></div>
+<div class="paragraph"><p>Cowboy may be compiled on other Erlang versions with small source code
+modifications but there is no guarantee that it will work as expected.</p></div>
+<div class="paragraph"><p>Cowboy uses the maps data type which was introduced in Erlang 17.0.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_versioning">Versioning</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Cowboy uses <a href="http://semver.org/">Semantic Versioning 2.0.0</a>.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_conventions">Conventions</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>In the HTTP protocol, the method name is case sensitive. All standard
+method names are uppercase.</p></div>
+<div class="paragraph"><p>Header names are case insensitive. Cowboy converts all the request
+header names to lowercase, and expects your application to provide
+lowercase header names in the response.</p></div>
+<div class="paragraph"><p>The same applies to any other case insensitive value.</p></div>
+</div>
+</div>
+ + + +</div> + +<div class="span3 sidecol"> + + +<h3> + Cowboy + 2.0 + + User Guide +</h3> + +<ul> + + <li><a href="/docs/en/cowboy/2.0/guide">User Guide</a></li> + + + <li><a href="/docs/en/cowboy/2.0/manual">Function Reference</a></li> + + +</ul> + +<h4 id="docs-nav">Navigation</h4> + +<h4>Version select</h4> +<ul> + + + + <li><a href="/docs/en/cowboy/1.0/guide">1.0</a></li> + + <li><a href="/docs/en/cowboy/2.0/guide">2.0</a></li> + +</ul> + +</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 © Loïc Hoguin 2012-2016</p> + </div> + </div> + </div> + </footer> + + + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> + <script src="/js/bootstrap-carousel.js"></script> + <script src="/js/bootstrap-dropdown.js"></script> + <script src="/js/custom.js"></script> + </body> +</html> + + diff --git a/docs/en/cowboy/2.0/guide/loop_handlers.asciidoc b/docs/en/cowboy/2.0/guide/loop_handlers.asciidoc new file mode 100644 index 00000000..58c42233 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/loop_handlers.asciidoc @@ -0,0 +1,146 @@ +[[loop_handlers]] +== Loop handlers + +Loop handlers are a special kind of HTTP handlers used when the +response can not be sent right away. The handler enters instead +a receive loop waiting for the right message before it can send +a response. + +Loop handlers are used for requests where a response might not +be immediately available, but where you would like to keep the +connection open for a while in case the response arrives. The +most known example of such practice is known as long polling. + +Loop handlers can also be used for requests where a response is +partially available and you need to stream the response body +while the connection is open. The most known example of such +practice is known as server-sent events. + +While the same can be accomplished using plain HTTP handlers, +it is recommended to use loop handlers because they are well-tested +and allow using built-in features like hibernation and timeouts. + +Loop handlers essentially wait for one or more Erlang messages +and feed these messages to the `info/3` callback. It also features +the `init/2` and `terminate/3` callbacks which work the same as +for plain HTTP handlers. + +=== Initialization + +The `init/2` function must return a `cowboy_loop` tuple to enable +loop handler behavior. This tuple may optionally contain +a timeout value and/or the atom `hibernate` to make the +process enter hibernation until a message is received. + +This snippet enables the loop handler. + +[source,erlang] +---- +init(Req, _Opts) -> + {cowboy_loop, Req, #state{}}. +---- + +However it is largely recommended that you set a timeout +value. The next example sets a timeout value of 30s and +also makes the process hibernate. + +[source,erlang] +---- +init(Req, _Opts) -> + {cowboy_loop, Req, #state{}, 30000, hibernate}. +---- + +=== Receive loop + +Once initialized, Cowboy will wait for messages to arrive +in the process' mailbox. When a message arrives, Cowboy +calls the `info/3` function with the message, the Req object +and the handler's state. + +The following snippet sends a reply when it receives a +`reply` message from another process, or waits for another +message otherwise. + +[source,erlang] +---- +info({reply, Body}, Req, State) -> + Req2 = cowboy_req:reply(200, [], Body, Req), + {stop, Req2, State}; +info(_Msg, Req, State) -> + {ok, Req, State, hibernate}. +---- + +Do note that the `reply` tuple here may be any message +and is simply an example. + +This callback may perform any necessary operation including +sending all or parts of a reply, and will subsequently +return a tuple indicating if more messages are to be expected. + +The callback may also choose to do nothing at all and just +skip the message received. + +If a reply is sent, then the `stop` tuple should be returned. +This will instruct Cowboy to end the request. + +Otherwise an `ok` tuple should be returned. + +=== Streaming loop + +Another common case well suited for loop handlers is +streaming data received in the form of Erlang messages. +This can be done by initiating a chunked reply in the +`init/2` callback and then using `cowboy_req:chunk/2` +every time a message is received. + +The following snippet does exactly that. As you can see +a chunk is sent every time a `chunk` message is received, +and the loop is stopped by sending an `eof` message. + +[source,erlang] +---- +init(Req, _Opts) -> + Req2 = cowboy_req:chunked_reply(200, [], Req), + {cowboy_loop, Req2, #state{}}. + +info(eof, Req, State) -> + {stop, Req, State}; +info({chunk, Chunk}, Req, State) -> + cowboy_req:chunk(Chunk, Req), + {ok, Req, State}; +info(_Msg, Req, State) -> + {ok, Req, State}. +---- + +==== Cleaning up + +It is recommended that you set the connection header to +`close` when replying, as this process may be reused for +a subsequent request. + +Please refer to the xref:handlers[Handlers chapter] +for general instructions about cleaning up. + +=== Timeout + +By default Cowboy will not attempt to close the connection +if there is no activity from the client. This is not always +desirable, which is why you can set a timeout. Cowboy will +close the connection if no data was received from the client +after the configured time. The timeout only needs to be set +once and can't be modified afterwards. + +Because the request may have had a body, or may be followed +by another request, Cowboy is forced to buffer all data it +receives. This data may grow to become too large though, +so there is a configurable limit for it. The default buffer +size is of 5000 bytes, but it may be changed by setting the +`loop_max_buffer` middleware environment value. + +=== Hibernate + +To save memory, you may hibernate the process in between +messages received. This is done by returning the atom +`hibernate` as part of the `loop` tuple callbacks normally +return. Just add the atom at the end and Cowboy will hibernate +accordingly. diff --git a/docs/en/cowboy/2.0/guide/loop_handlers/index.html b/docs/en/cowboy/2.0/guide/loop_handlers/index.html new file mode 100644 index 00000000..d3081aac --- /dev/null +++ b/docs/en/cowboy/2.0/guide/loop_handlers/index.html @@ -0,0 +1,284 @@ +<!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"> + + <meta name="generator" content="Hugo 0.15" /> + + <title>Nine Nines: Loop handlers</title> + + <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'> + + <link href="/css/bootstrap.min.css" rel="stylesheet"> + <link href="/css/99s.css" 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="Keep in touch!" href="http://twitter.com/lhoguin"><img src="/img/ico_microblog.png" data-hover="/img/ico_microblog_alt.png"></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>Loop handlers</span></h1> + +<div class="paragraph"><p>Loop handlers are a special kind of HTTP handlers used when the
+response can not be sent right away. The handler enters instead
+a receive loop waiting for the right message before it can send
+a response.</p></div>
+<div class="paragraph"><p>Loop handlers are used for requests where a response might not
+be immediately available, but where you would like to keep the
+connection open for a while in case the response arrives. The
+most known example of such practice is known as long polling.</p></div>
+<div class="paragraph"><p>Loop handlers can also be used for requests where a response is
+partially available and you need to stream the response body
+while the connection is open. The most known example of such
+practice is known as server-sent events.</p></div>
+<div class="paragraph"><p>While the same can be accomplished using plain HTTP handlers,
+it is recommended to use loop handlers because they are well-tested
+and allow using built-in features like hibernation and timeouts.</p></div>
+<div class="paragraph"><p>Loop handlers essentially wait for one or more Erlang messages
+and feed these messages to the <code>info/3</code> callback. It also features
+the <code>init/2</code> and <code>terminate/3</code> callbacks which work the same as
+for plain HTTP handlers.</p></div>
+<div class="sect1">
+<h2 id="_initialization">Initialization</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>The <code>init/2</code> function must return a <code>cowboy_loop</code> tuple to enable
+loop handler behavior. This tuple may optionally contain
+a timeout value and/or the atom <code>hibernate</code> to make the
+process enter hibernation until a message is received.</p></div>
+<div class="paragraph"><p>This snippet enables the loop handler.</p></div>
+<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">init</span></span>(<span style="color: #009900">Req</span>, <span style="color: #009900">_Opts</span>) <span style="color: #990000">-></span>
+ {<span style="color: #FF6600">cowboy_loop</span>, <span style="color: #009900">Req</span>, <span style="color: #008080">#state</span>{}}<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>However it is largely recommended that you set a timeout
+value. The next example sets a timeout value of 30s and
+also makes the process hibernate.</p></div>
+<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">init</span></span>(<span style="color: #009900">Req</span>, <span style="color: #009900">_Opts</span>) <span style="color: #990000">-></span>
+ {<span style="color: #FF6600">cowboy_loop</span>, <span style="color: #009900">Req</span>, <span style="color: #008080">#state</span>{}, <span style="color: #993399">30000</span>, <span style="color: #FF6600">hibernate</span>}<span style="color: #990000">.</span></tt></pre></div></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_receive_loop">Receive loop</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Once initialized, Cowboy will wait for messages to arrive
+in the process' mailbox. When a message arrives, Cowboy
+calls the <code>info/3</code> function with the message, the Req object
+and the handler’s state.</p></div>
+<div class="paragraph"><p>The following snippet sends a reply when it receives a
+<code>reply</code> message from another process, or waits for another
+message otherwise.</p></div>
+<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">info</span></span>({<span style="color: #FF6600">reply</span>, <span style="color: #009900">Body</span>}, <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>) <span style="color: #990000">-></span>
+ <span style="color: #009900">Req2</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:reply</span></span>(<span style="color: #993399">200</span>, [], <span style="color: #009900">Body</span>, <span style="color: #009900">Req</span>),
+ {<span style="color: #FF6600">stop</span>, <span style="color: #009900">Req2</span>, <span style="color: #009900">State</span>};
+<span style="font-weight: bold"><span style="color: #000000">info</span></span>(<span style="color: #009900">_Msg</span>, <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>) <span style="color: #990000">-></span>
+ {<span style="color: #FF6600">ok</span>, <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>, <span style="color: #FF6600">hibernate</span>}<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Do note that the <code>reply</code> tuple here may be any message
+and is simply an example.</p></div>
+<div class="paragraph"><p>This callback may perform any necessary operation including
+sending all or parts of a reply, and will subsequently
+return a tuple indicating if more messages are to be expected.</p></div>
+<div class="paragraph"><p>The callback may also choose to do nothing at all and just
+skip the message received.</p></div>
+<div class="paragraph"><p>If a reply is sent, then the <code>stop</code> tuple should be returned.
+This will instruct Cowboy to end the request.</p></div>
+<div class="paragraph"><p>Otherwise an <code>ok</code> tuple should be returned.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_streaming_loop">Streaming loop</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Another common case well suited for loop handlers is
+streaming data received in the form of Erlang messages.
+This can be done by initiating a chunked reply in the
+<code>init/2</code> callback and then using <code>cowboy_req:chunk/2</code>
+every time a message is received.</p></div>
+<div class="paragraph"><p>The following snippet does exactly that. As you can see
+a chunk is sent every time a <code>chunk</code> message is received,
+and the loop is stopped by sending an <code>eof</code> message.</p></div>
+<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">init</span></span>(<span style="color: #009900">Req</span>, <span style="color: #009900">_Opts</span>) <span style="color: #990000">-></span>
+ <span style="color: #009900">Req2</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:chunked_reply</span></span>(<span style="color: #993399">200</span>, [], <span style="color: #009900">Req</span>),
+ {<span style="color: #FF6600">cowboy_loop</span>, <span style="color: #009900">Req2</span>, <span style="color: #008080">#state</span>{}}<span style="color: #990000">.</span>
+
+<span style="font-weight: bold"><span style="color: #000000">info</span></span>(<span style="color: #FF6600">eof</span>, <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>) <span style="color: #990000">-></span>
+ {<span style="color: #FF6600">stop</span>, <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>};
+<span style="font-weight: bold"><span style="color: #000000">info</span></span>({<span style="color: #FF6600">chunk</span>, <span style="color: #009900">Chunk</span>}, <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>) <span style="color: #990000">-></span>
+ <span style="font-weight: bold"><span style="color: #000000">cowboy_req:chunk</span></span>(<span style="color: #009900">Chunk</span>, <span style="color: #009900">Req</span>),
+ {<span style="color: #FF6600">ok</span>, <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>};
+<span style="font-weight: bold"><span style="color: #000000">info</span></span>(<span style="color: #009900">_Msg</span>, <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>) <span style="color: #990000">-></span>
+ {<span style="color: #FF6600">ok</span>, <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>}<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="sect3">
+<h4 id="_cleaning_up">Cleaning up</h4>
+<div class="paragraph"><p>It is recommended that you set the connection header to
+<code>close</code> when replying, as this process may be reused for
+a subsequent request.</p></div>
+<div class="paragraph"><p>Please refer to the <a href="../handlers">Handlers chapter</a>
+for general instructions about cleaning up.</p></div>
+</div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_timeout">Timeout</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>By default Cowboy will not attempt to close the connection
+if there is no activity from the client. This is not always
+desirable, which is why you can set a timeout. Cowboy will
+close the connection if no data was received from the client
+after the configured time. The timeout only needs to be set
+once and can’t be modified afterwards.</p></div>
+<div class="paragraph"><p>Because the request may have had a body, or may be followed
+by another request, Cowboy is forced to buffer all data it
+receives. This data may grow to become too large though,
+so there is a configurable limit for it. The default buffer
+size is of 5000 bytes, but it may be changed by setting the
+<code>loop_max_buffer</code> middleware environment value.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_hibernate">Hibernate</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>To save memory, you may hibernate the process in between
+messages received. This is done by returning the atom
+<code>hibernate</code> as part of the <code>loop</code> tuple callbacks normally
+return. Just add the atom at the end and Cowboy will hibernate
+accordingly.</p></div>
+</div>
+</div>
+ + + +</div> + +<div class="span3 sidecol"> + + +<h3> + Cowboy + 2.0 + + User Guide +</h3> + +<ul> + + <li><a href="/docs/en/cowboy/2.0/guide">User Guide</a></li> + + + <li><a href="/docs/en/cowboy/2.0/manual">Function Reference</a></li> + + +</ul> + +<h4 id="docs-nav">Navigation</h4> + +<h4>Version select</h4> +<ul> + + + + <li><a href="/docs/en/cowboy/1.0/guide">1.0</a></li> + + <li><a href="/docs/en/cowboy/2.0/guide">2.0</a></li> + +</ul> + +</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 © Loïc Hoguin 2012-2016</p> + </div> + </div> + </div> + </footer> + + + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> + <script src="/js/bootstrap-carousel.js"></script> + <script src="/js/bootstrap-dropdown.js"></script> + <script src="/js/custom.js"></script> + </body> +</html> + + diff --git a/docs/en/cowboy/2.0/guide/middlewares.asciidoc b/docs/en/cowboy/2.0/guide/middlewares.asciidoc new file mode 100644 index 00000000..e6be30dd --- /dev/null +++ b/docs/en/cowboy/2.0/guide/middlewares.asciidoc @@ -0,0 +1,69 @@ +[[middlewares]] +== Middlewares + +Cowboy delegates the request processing to middleware components. +By default, two middlewares are defined, for the routing and handling +of the request, as is detailed in most of this guide. + +Middlewares give you complete control over how requests are to be +processed. You can add your own middlewares to the mix or completely +change the chain of middlewares as needed. + +Cowboy will execute all middlewares in the given order, unless one +of them decides to stop processing. + +=== Usage + +Middlewares only need to implement a single callback: `execute/2`. +It is defined in the `cowboy_middleware` behavior. + +This callback has two arguments. The first is the `Req` object. +The second is the environment. + +Middlewares can return one of three different values: + +* `{ok, Req, Env}` to continue the request processing +* `{suspend, Module, Function, Args}` to hibernate +* `{stop, Req}` to stop processing and move on to the next request + +Of note is that when hibernating, processing will resume on the given +MFA, discarding all previous stacktrace. Make sure you keep the `Req` +and `Env` in the arguments of this MFA for later use. + +If an error happens during middleware processing, Cowboy will not try +to send an error back to the socket, the process will just crash. It +is up to the middleware to make sure that a reply is sent if something +goes wrong. + +=== Configuration + +The middleware environment is defined as the `env` protocol option. +In the previous chapters we saw it briefly when we needed to pass +the routing information. It is a list of tuples with the first +element being an atom and the second any Erlang term. + +Two values in the environment are reserved: + +* `listener` contains the name of the listener +* `result` contains the result of the processing + +The `listener` value is always defined. The `result` value can be +set by any middleware. If set to anything other than `ok`, Cowboy +will not process any subsequent requests on this connection. + +The middlewares that come with Cowboy may define or require other +environment values to perform. + +You can update the environment by calling the `cowboy:set_env/3` +convenience function, adding or replacing a value in the environment. + +=== Routing middleware + +The routing middleware requires the `dispatch` value. If routing +succeeds, it will put the handler name and options in the `handler` +and `handler_opts` values of the environment, respectively. + +=== Handler middleware + +The handler middleware requires the `handler` and `handler_opts` +values. It puts the result of the request handling into `result`. diff --git a/docs/en/cowboy/2.0/guide/middlewares/index.html b/docs/en/cowboy/2.0/guide/middlewares/index.html new file mode 100644 index 00000000..09894d10 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/middlewares/index.html @@ -0,0 +1,228 @@ +<!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"> + + <meta name="generator" content="Hugo 0.15" /> + + <title>Nine Nines: Middlewares</title> + + <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'> + + <link href="/css/bootstrap.min.css" rel="stylesheet"> + <link href="/css/99s.css" 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="Keep in touch!" href="http://twitter.com/lhoguin"><img src="/img/ico_microblog.png" data-hover="/img/ico_microblog_alt.png"></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>Middlewares</span></h1> + +<div class="paragraph"><p>Cowboy delegates the request processing to middleware components.
+By default, two middlewares are defined, for the routing and handling
+of the request, as is detailed in most of this guide.</p></div>
+<div class="paragraph"><p>Middlewares give you complete control over how requests are to be
+processed. You can add your own middlewares to the mix or completely
+change the chain of middlewares as needed.</p></div>
+<div class="paragraph"><p>Cowboy will execute all middlewares in the given order, unless one
+of them decides to stop processing.</p></div>
+<div class="sect1">
+<h2 id="_usage">Usage</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Middlewares only need to implement a single callback: <code>execute/2</code>.
+It is defined in the <code>cowboy_middleware</code> behavior.</p></div>
+<div class="paragraph"><p>This callback has two arguments. The first is the <code>Req</code> object.
+The second is the environment.</p></div>
+<div class="paragraph"><p>Middlewares can return one of three different values:</p></div>
+<div class="ulist"><ul>
+<li>
+<p>
+<code>{ok, Req, Env}</code> to continue the request processing
+</p>
+</li>
+<li>
+<p>
+<code>{suspend, Module, Function, Args}</code> to hibernate
+</p>
+</li>
+<li>
+<p>
+<code>{stop, Req}</code> to stop processing and move on to the next request
+</p>
+</li>
+</ul></div>
+<div class="paragraph"><p>Of note is that when hibernating, processing will resume on the given
+MFA, discarding all previous stacktrace. Make sure you keep the <code>Req</code>
+and <code>Env</code> in the arguments of this MFA for later use.</p></div>
+<div class="paragraph"><p>If an error happens during middleware processing, Cowboy will not try
+to send an error back to the socket, the process will just crash. It
+is up to the middleware to make sure that a reply is sent if something
+goes wrong.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_configuration">Configuration</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>The middleware environment is defined as the <code>env</code> protocol option.
+In the previous chapters we saw it briefly when we needed to pass
+the routing information. It is a list of tuples with the first
+element being an atom and the second any Erlang term.</p></div>
+<div class="paragraph"><p>Two values in the environment are reserved:</p></div>
+<div class="ulist"><ul>
+<li>
+<p>
+<code>listener</code> contains the name of the listener
+</p>
+</li>
+<li>
+<p>
+<code>result</code> contains the result of the processing
+</p>
+</li>
+</ul></div>
+<div class="paragraph"><p>The <code>listener</code> value is always defined. The <code>result</code> value can be
+set by any middleware. If set to anything other than <code>ok</code>, Cowboy
+will not process any subsequent requests on this connection.</p></div>
+<div class="paragraph"><p>The middlewares that come with Cowboy may define or require other
+environment values to perform.</p></div>
+<div class="paragraph"><p>You can update the environment by calling the <code>cowboy:set_env/3</code>
+convenience function, adding or replacing a value in the environment.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_routing_middleware">Routing middleware</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>The routing middleware requires the <code>dispatch</code> value. If routing
+succeeds, it will put the handler name and options in the <code>handler</code>
+and <code>handler_opts</code> values of the environment, respectively.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_handler_middleware">Handler middleware</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>The handler middleware requires the <code>handler</code> and <code>handler_opts</code>
+values. It puts the result of the request handling into <code>result</code>.</p></div>
+</div>
+</div>
+ + + +</div> + +<div class="span3 sidecol"> + + +<h3> + Cowboy + 2.0 + + User Guide +</h3> + +<ul> + + <li><a href="/docs/en/cowboy/2.0/guide">User Guide</a></li> + + + <li><a href="/docs/en/cowboy/2.0/manual">Function Reference</a></li> + + +</ul> + +<h4 id="docs-nav">Navigation</h4> + +<h4>Version select</h4> +<ul> + + + + <li><a href="/docs/en/cowboy/1.0/guide">1.0</a></li> + + <li><a href="/docs/en/cowboy/2.0/guide">2.0</a></li> + +</ul> + +</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 © Loïc Hoguin 2012-2016</p> + </div> + </div> + </div> + </footer> + + + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> + <script src="/js/bootstrap-carousel.js"></script> + <script src="/js/bootstrap-dropdown.js"></script> + <script src="/js/custom.js"></script> + </body> +</html> + + diff --git a/docs/en/cowboy/2.0/guide/modern_web.asciidoc b/docs/en/cowboy/2.0/guide/modern_web.asciidoc new file mode 100644 index 00000000..732972f0 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/modern_web.asciidoc @@ -0,0 +1,200 @@ +[[modern_web]] +== The modern Web + +Let's take a look at various technologies from the beginnings +of the Web up to this day, and get a preview of what's +coming next. + +Cowboy is compatible with all the technology cited in this +chapter except of course HTTP/2.0 which has no implementation +in the wild at the time of writing. + +=== The prehistoric Web + +HTTP was initially created to serve HTML pages and only +had the GET method for retrieving them. This initial +version is documented and is sometimes called HTTP/0.9. +HTTP/1.0 defined the GET, HEAD and POST methods, and +was able to send data with POST requests. + +HTTP/1.0 works in a very simple way. A TCP connection +is first established to the server. Then a request is +sent. Then the server sends a response back and closes +the connection. + +Suffice to say, HTTP/1.0 is not very efficient. Opening +a TCP connection takes some time, and pages containing +many assets load much slower than they could because of +this. + +Most improvements done in recent years focused on reducing +this load time and reducing the latency of the requests. + +=== HTTP/1.1 + +HTTP/1.1 quickly followed and added a keep-alive mechanism +to allow using the same connection for many requests, as +well as streaming capabilities, allowing an endpoint to send +a body in well defined chunks. + +HTTP/1.1 defines the OPTIONS, GET, HEAD, POST, PUT, DELETE, +TRACE and CONNECT methods. The PATCH method was added in more +recent years. It also improves the caching capabilities with +the introduction of many headers. + +HTTP/1.1 still works like HTTP/1.0 does, except the connection +can be kept alive for subsequent requests. This however allows +clients to perform what is called as pipelining: sending many +requests in a row, and then processing the responses which will +be received in the same order as the requests. + +=== REST + +The design of HTTP/1.1 was influenced by the REST architectural +style. REST, or REpresentational State Transfer, is a style of +architecture for loosely connected distributed systems. + +REST defines constraints that systems must obey to in order to +be RESTful. A system which doesn't follow all the constraints +cannot be considered RESTful. + +REST is a client-server architecture with a clean separation +of concerns between the client and the server. They communicate +by referencing resources. Resources can be identified, but +also manipulated. A resource representation has a media type +and information about whether it can be cached and how. Hypermedia +determines how resources are related and how they can be used. +REST is also stateless. All requests contain the complete +information necessary to perform the action. + +HTTP/1.1 defines all the methods, headers and semantics required +to implement RESTful systems. + +REST is most often used when designing web application APIs +which are generally meant to be used by executable code directly. + +=== XmlHttpRequest + +Also know as AJAX, this technology allows Javascript code running +on a web page to perform asynchronous requests to the server. +This is what started the move from static websites to dynamic +web applications. + +XmlHttpRequest still performs HTTP requests under the hood, +and then waits for a response, but the Javascript code can +continue to run until the response arrives. It will then receive +the response through a callback previously defined. + +This is of course still requests initiated by the client, +the server still had no way of pushing data to the client +on its own, so new technology appeared to allow that. + +=== Long-polling + +Polling was a technique used to overcome the fact that the server +cannot push data directly to the client. Therefore the client had +to repeatedly create a connection, make a request, get a response, +then try again a few seconds later. This is overly expensive and +adds an additional delay before the client receives the data. + +Polling was necessary to implement message queues and other +similar mechanisms, where a user must be informed of something +when it happens, rather than when he refreshes the page next. +A typical example would be a chat application. + +Long-polling was created to reduce the server load by creating +less connections, but also to improve latency by getting the +response back to the client as soon as it becomes available +on the server. + +Long-polling works in a similar manner to polling, except the +request will not get a response immediately. Instead the server +leaves it open until it has a response to send. After getting +the response, the client creates a new request and gets back +to waiting. + +You probably guessed by now that long-polling is a hack, and +like most hacks it can suffer from unforeseen issues, in this +case it doesn't always play well with proxies. + +=== HTML5 + +HTML5 is, of course, the HTML version after HTML4. But HTML5 +emerged to solve a specific problem: dynamic web applications. + +HTML was initially created to write web pages which compose +a website. But soon people and companies wanted to use HTML +to write more and more complex websites, eventually known as +web applications. They are for example your news reader, your +email client in the browser, or your video streaming website. + +Because HTML wasn't enough, they started using proprietary +solutions, often implemented using plug-ins. This wasn't +perfect of course, but worked well enough for most people. + +However, the needs for a standard solution eventually became +apparent. The browser needed to be able to play media natively. +It needed to be able to draw anything. It needed an efficient +way of streaming events to the server, but also receiving +events from the server. + +The solution went on to become HTML5. At the time of writing +it is being standardized. + +=== EventSource + +EventSource, sometimes also called Server-Sent Events, is a +technology allowing servers to push data to HTML5 applications. + +EventSource is one-way communication channel from the server +to the client. The client has no means to talk to the server +other than by using HTTP requests. + +It consists of a Javascript object allowing setting up an +EventSource connection to the server, and a very small protocol +for sending events to the client on top of the HTTP/1.1 +connection. + +EventSource is a lightweight solution that only works for +UTF-8 encoded text data. Binary data and text data encoded +differently are not allowed by the protocol. A heavier but +more generic approach can be found in Websocket. + +=== Websocket + +Websocket is a protocol built on top of HTTP/1.1 that provides +a two-ways communication channel between the client and the +server. Communication is asynchronous and can occur concurrently. + +It consists of a Javascript object allowing setting up a +Websocket connection to the server, and a binary based +protocol for sending data to the server or the client. + +Websocket connections can transfer either UTF-8 encoded text +data or binary data. The protocol also includes support for +implementing a ping/pong mechanism, allowing the server and +the client to have more confidence that the connection is still +alive. + +A Websocket connection can be used to transfer any kind of data, +small or big, text or binary. Because of this Websocket is +sometimes used for communication between systems. + +=== HTTP/2 + +HTTP/2 is an attempt to reduce page loading time by opening a +single connection per server, keeping it open for subsequent +requests, and also by compressing the HTTP headers to reduce +the size of requests. + +HTTP/2 is compatible with HTTP/1.1 semantics, and is actually +just a different way of performing HTTP requests and responses, +by using binary frames instead of a text-based protocol. +HTTP/2 also allows the server to send extra responses following +a request. This is meant to allow sending the resources +associated with the request before the client requests them, +saving latency when loading websites. + +Browsers make use of TLS Application-Layer Protocol Negotiation +extension to upgrade to an HTTP/2 connection seamlessly if the +server supports it. diff --git a/docs/en/cowboy/2.0/guide/modern_web/index.html b/docs/en/cowboy/2.0/guide/modern_web/index.html new file mode 100644 index 00000000..69761906 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/modern_web/index.html @@ -0,0 +1,329 @@ +<!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"> + + <meta name="generator" content="Hugo 0.15" /> + + <title>Nine Nines: The modern Web</title> + + <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'> + + <link href="/css/bootstrap.min.css" rel="stylesheet"> + <link href="/css/99s.css" 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="Keep in touch!" href="http://twitter.com/lhoguin"><img src="/img/ico_microblog.png" data-hover="/img/ico_microblog_alt.png"></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>The modern Web</span></h1> + +<div class="paragraph"><p>Let’s take a look at various technologies from the beginnings
+of the Web up to this day, and get a preview of what’s
+coming next.</p></div>
+<div class="paragraph"><p>Cowboy is compatible with all the technology cited in this
+chapter except of course HTTP/2.0 which has no implementation
+in the wild at the time of writing.</p></div>
+<div class="sect1">
+<h2 id="_the_prehistoric_web">The prehistoric Web</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>HTTP was initially created to serve HTML pages and only
+had the GET method for retrieving them. This initial
+version is documented and is sometimes called HTTP/0.9.
+HTTP/1.0 defined the GET, HEAD and POST methods, and
+was able to send data with POST requests.</p></div>
+<div class="paragraph"><p>HTTP/1.0 works in a very simple way. A TCP connection
+is first established to the server. Then a request is
+sent. Then the server sends a response back and closes
+the connection.</p></div>
+<div class="paragraph"><p>Suffice to say, HTTP/1.0 is not very efficient. Opening
+a TCP connection takes some time, and pages containing
+many assets load much slower than they could because of
+this.</p></div>
+<div class="paragraph"><p>Most improvements done in recent years focused on reducing
+this load time and reducing the latency of the requests.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_http_1_1">HTTP/1.1</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>HTTP/1.1 quickly followed and added a keep-alive mechanism
+to allow using the same connection for many requests, as
+well as streaming capabilities, allowing an endpoint to send
+a body in well defined chunks.</p></div>
+<div class="paragraph"><p>HTTP/1.1 defines the OPTIONS, GET, HEAD, POST, PUT, DELETE,
+TRACE and CONNECT methods. The PATCH method was added in more
+recent years. It also improves the caching capabilities with
+the introduction of many headers.</p></div>
+<div class="paragraph"><p>HTTP/1.1 still works like HTTP/1.0 does, except the connection
+can be kept alive for subsequent requests. This however allows
+clients to perform what is called as pipelining: sending many
+requests in a row, and then processing the responses which will
+be received in the same order as the requests.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_rest">REST</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>The design of HTTP/1.1 was influenced by the REST architectural
+style. REST, or REpresentational State Transfer, is a style of
+architecture for loosely connected distributed systems.</p></div>
+<div class="paragraph"><p>REST defines constraints that systems must obey to in order to
+be RESTful. A system which doesn’t follow all the constraints
+cannot be considered RESTful.</p></div>
+<div class="paragraph"><p>REST is a client-server architecture with a clean separation
+of concerns between the client and the server. They communicate
+by referencing resources. Resources can be identified, but
+also manipulated. A resource representation has a media type
+and information about whether it can be cached and how. Hypermedia
+determines how resources are related and how they can be used.
+REST is also stateless. All requests contain the complete
+information necessary to perform the action.</p></div>
+<div class="paragraph"><p>HTTP/1.1 defines all the methods, headers and semantics required
+to implement RESTful systems.</p></div>
+<div class="paragraph"><p>REST is most often used when designing web application APIs
+which are generally meant to be used by executable code directly.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_xmlhttprequest">XmlHttpRequest</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Also know as AJAX, this technology allows Javascript code running
+on a web page to perform asynchronous requests to the server.
+This is what started the move from static websites to dynamic
+web applications.</p></div>
+<div class="paragraph"><p>XmlHttpRequest still performs HTTP requests under the hood,
+and then waits for a response, but the Javascript code can
+continue to run until the response arrives. It will then receive
+the response through a callback previously defined.</p></div>
+<div class="paragraph"><p>This is of course still requests initiated by the client,
+the server still had no way of pushing data to the client
+on its own, so new technology appeared to allow that.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_long_polling">Long-polling</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Polling was a technique used to overcome the fact that the server
+cannot push data directly to the client. Therefore the client had
+to repeatedly create a connection, make a request, get a response,
+then try again a few seconds later. This is overly expensive and
+adds an additional delay before the client receives the data.</p></div>
+<div class="paragraph"><p>Polling was necessary to implement message queues and other
+similar mechanisms, where a user must be informed of something
+when it happens, rather than when he refreshes the page next.
+A typical example would be a chat application.</p></div>
+<div class="paragraph"><p>Long-polling was created to reduce the server load by creating
+less connections, but also to improve latency by getting the
+response back to the client as soon as it becomes available
+on the server.</p></div>
+<div class="paragraph"><p>Long-polling works in a similar manner to polling, except the
+request will not get a response immediately. Instead the server
+leaves it open until it has a response to send. After getting
+the response, the client creates a new request and gets back
+to waiting.</p></div>
+<div class="paragraph"><p>You probably guessed by now that long-polling is a hack, and
+like most hacks it can suffer from unforeseen issues, in this
+case it doesn’t always play well with proxies.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_html5">HTML5</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>HTML5 is, of course, the HTML version after HTML4. But HTML5
+emerged to solve a specific problem: dynamic web applications.</p></div>
+<div class="paragraph"><p>HTML was initially created to write web pages which compose
+a website. But soon people and companies wanted to use HTML
+to write more and more complex websites, eventually known as
+web applications. They are for example your news reader, your
+email client in the browser, or your video streaming website.</p></div>
+<div class="paragraph"><p>Because HTML wasn’t enough, they started using proprietary
+solutions, often implemented using plug-ins. This wasn’t
+perfect of course, but worked well enough for most people.</p></div>
+<div class="paragraph"><p>However, the needs for a standard solution eventually became
+apparent. The browser needed to be able to play media natively.
+It needed to be able to draw anything. It needed an efficient
+way of streaming events to the server, but also receiving
+events from the server.</p></div>
+<div class="paragraph"><p>The solution went on to become HTML5. At the time of writing
+it is being standardized.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_eventsource">EventSource</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>EventSource, sometimes also called Server-Sent Events, is a
+technology allowing servers to push data to HTML5 applications.</p></div>
+<div class="paragraph"><p>EventSource is one-way communication channel from the server
+to the client. The client has no means to talk to the server
+other than by using HTTP requests.</p></div>
+<div class="paragraph"><p>It consists of a Javascript object allowing setting up an
+EventSource connection to the server, and a very small protocol
+for sending events to the client on top of the HTTP/1.1
+connection.</p></div>
+<div class="paragraph"><p>EventSource is a lightweight solution that only works for
+UTF-8 encoded text data. Binary data and text data encoded
+differently are not allowed by the protocol. A heavier but
+more generic approach can be found in Websocket.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_websocket">Websocket</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Websocket is a protocol built on top of HTTP/1.1 that provides
+a two-ways communication channel between the client and the
+server. Communication is asynchronous and can occur concurrently.</p></div>
+<div class="paragraph"><p>It consists of a Javascript object allowing setting up a
+Websocket connection to the server, and a binary based
+protocol for sending data to the server or the client.</p></div>
+<div class="paragraph"><p>Websocket connections can transfer either UTF-8 encoded text
+data or binary data. The protocol also includes support for
+implementing a ping/pong mechanism, allowing the server and
+the client to have more confidence that the connection is still
+alive.</p></div>
+<div class="paragraph"><p>A Websocket connection can be used to transfer any kind of data,
+small or big, text or binary. Because of this Websocket is
+sometimes used for communication between systems.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_http_2">HTTP/2</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>HTTP/2 is an attempt to reduce page loading time by opening a
+single connection per server, keeping it open for subsequent
+requests, and also by compressing the HTTP headers to reduce
+the size of requests.</p></div>
+<div class="paragraph"><p>HTTP/2 is compatible with HTTP/1.1 semantics, and is actually
+just a different way of performing HTTP requests and responses,
+by using binary frames instead of a text-based protocol.
+HTTP/2 also allows the server to send extra responses following
+a request. This is meant to allow sending the resources
+associated with the request before the client requests them,
+saving latency when loading websites.</p></div>
+<div class="paragraph"><p>Browsers make use of TLS Application-Layer Protocol Negotiation
+extension to upgrade to an HTTP/2 connection seamlessly if the
+server supports it.</p></div>
+</div>
+</div>
+ + + +</div> + +<div class="span3 sidecol"> + + +<h3> + Cowboy + 2.0 + + User Guide +</h3> + +<ul> + + <li><a href="/docs/en/cowboy/2.0/guide">User Guide</a></li> + + + <li><a href="/docs/en/cowboy/2.0/manual">Function Reference</a></li> + + +</ul> + +<h4 id="docs-nav">Navigation</h4> + +<h4>Version select</h4> +<ul> + + + + <li><a href="/docs/en/cowboy/1.0/guide">1.0</a></li> + + <li><a href="/docs/en/cowboy/2.0/guide">2.0</a></li> + +</ul> + +</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 © Loïc Hoguin 2012-2016</p> + </div> + </div> + </div> + </footer> + + + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> + <script src="/js/bootstrap-carousel.js"></script> + <script src="/js/bootstrap-dropdown.js"></script> + <script src="/js/custom.js"></script> + </body> +</html> + + diff --git a/docs/en/cowboy/2.0/guide/multipart.asciidoc b/docs/en/cowboy/2.0/guide/multipart.asciidoc new file mode 100644 index 00000000..20d53d51 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/multipart.asciidoc @@ -0,0 +1,169 @@ +[[multipart]] +== Multipart requests + +Multipart originates from MIME, an Internet standard that +extends the format of emails. Multipart messages are a +container for parts of any content-type. + +For example, a multipart message may have a part +containing text and a second part containing an +image. This is what allows you to attach files +to emails. + +In the context of HTTP, multipart is most often used +with the `multipart/form-data` content-type. This is +the content-type you have to use when you want browsers +to be allowed to upload files through HTML forms. + +Multipart is of course not required for uploading +files, it is only required when you want to do so +through HTML forms. + +You can read and parse multipart messages using the +Req object directly. + +Cowboy defines two functions that allows you to get +information about each part and read their contents. + +=== Structure + +A multipart message is a list of parts. Parts may +contain either a multipart message or a non-multipart +content-type. This allows parts to be arranged in a +tree structure, although this is a rare case as far +as the Web is concerned. + +=== Form-data + +In the normal case, when a form is submitted, the +browser will use the `application/x-www-form-urlencoded` +content-type. This type is just a list of keys and +values and is therefore not fit for uploading files. + +That's where the `multipart/form-data` content-type +comes in. When the form is configured to use this +content-type, the browser will use one part of the +message for each form field. This means that a file +input field will be sent in its own part, but the +same applies to all other kinds of fields. + +A form with a text input, a file input and a select +choice box will result in a multipart message with +three parts, one for each field. + +The browser does its best to determine the content-type +of the files it sends this way, but you should not +rely on it for determining the contents of the file. +Proper investigation of the contents is recommended. + +=== Checking the content-type + +While there is a variety of multipart messages, the +most common on the Web is `multipart/form-data`. It's +the type of message being sent when an HTML form +allows uploading files. + +You can quickly figure out if a multipart message +has been sent by parsing the `content-type` header. + +[source,erlang] +---- +{<<"multipart">>, <<"form-data">>, _} + = cowboy_req:parse_header(<<"content-type">>, Req). +---- + +=== Reading a multipart message + +To read a message you have to iterate over all its +parts. Then, for each part, you can inspect its headers +and read its body. + +[source,erlang] +---- +multipart(Req) -> + case cowboy_req:part(Req) of + {ok, _Headers, Req2} -> + {ok, _Body, Req3} = cowboy_req:part_body(Req2), + multipart(Req3); + {done, Req2} -> + Req2 + end. +---- + +Parts do not have a size limit. When a part body is +too big, Cowboy will return what it read so far and +allow you to continue if you wish to do so. + +The function `cow_multipart:form_data/1` can be used +to quickly obtain information about a part from a +`multipart/form-data` message. This function will +tell you if the part is for a normal field or if it +is a file being uploaded. + +This can be used for example to allow large part bodies +for files but crash when a normal field is too large. + +[source,erlang] +---- +multipart(Req) -> + case cowboy_req:part(Req) of + {ok, Headers, Req2} -> + Req4 = case cow_multipart:form_data(Headers) of + {data, _FieldName} -> + {ok, _Body, Req3} = cowboy_req:part_body(Req2), + Req3; + {file, _FieldName, _Filename, _CType, _CTransferEncoding} -> + stream_file(Req2) + end, + multipart(Req4); + {done, Req2} -> + Req2 + end. + +stream_file(Req) -> + case cowboy_req:part_body(Req) of + {ok, _Body, Req2} -> + Req2; + {more, _Body, Req2} -> + stream_file(Req2) + end. +---- + +By default the body chunk Cowboy will return is limited +to 8MB. This can of course be overriden. Both functions +can take a second argument, the same list of options that +will be passed to `cowboy_req:body/2` function. + +=== Skipping unwanted parts + +If you do not want to read a part's body, you can skip it. +Skipping is easy. If you do not call the function to read +the part's body, Cowboy will automatically skip it when +you request the next part. + +The following snippet reads all part headers and skips +all bodies: + +[source,erlang] +---- +multipart(Req) -> + case cowboy_req:part(Req) of + {ok, _Headers, Req2} -> + multipart(Req2); + {done, Req2} -> + Req2 + end. +---- + +Similarly, if you start reading the body and it ends up +being too big, you can simply continue with the next part, +Cowboy will automatically skip what remains. + +Note that the skipping rate may not be adequate for your +application. If you observe poor performance when skipping, +you might want to consider manually skipping by calling +the `cowboy_req:part_body/1` function directly. + +And if you started reading the message but decide that you +do not need the remaining parts, you can simply stop reading +entirely and Cowboy will automatically figure out what to do. diff --git a/docs/en/cowboy/2.0/guide/multipart/index.html b/docs/en/cowboy/2.0/guide/multipart/index.html new file mode 100644 index 00000000..2a443f10 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/multipart/index.html @@ -0,0 +1,305 @@ +<!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"> + + <meta name="generator" content="Hugo 0.15" /> + + <title>Nine Nines: Multipart requests</title> + + <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'> + + <link href="/css/bootstrap.min.css" rel="stylesheet"> + <link href="/css/99s.css" 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="Keep in touch!" href="http://twitter.com/lhoguin"><img src="/img/ico_microblog.png" data-hover="/img/ico_microblog_alt.png"></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>Multipart requests</span></h1> + +<div class="paragraph"><p>Multipart originates from MIME, an Internet standard that
+extends the format of emails. Multipart messages are a
+container for parts of any content-type.</p></div>
+<div class="paragraph"><p>For example, a multipart message may have a part
+containing text and a second part containing an
+image. This is what allows you to attach files
+to emails.</p></div>
+<div class="paragraph"><p>In the context of HTTP, multipart is most often used
+with the <code>multipart/form-data</code> content-type. This is
+the content-type you have to use when you want browsers
+to be allowed to upload files through HTML forms.</p></div>
+<div class="paragraph"><p>Multipart is of course not required for uploading
+files, it is only required when you want to do so
+through HTML forms.</p></div>
+<div class="paragraph"><p>You can read and parse multipart messages using the
+Req object directly.</p></div>
+<div class="paragraph"><p>Cowboy defines two functions that allows you to get
+information about each part and read their contents.</p></div>
+<div class="sect1">
+<h2 id="_structure">Structure</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>A multipart message is a list of parts. Parts may
+contain either a multipart message or a non-multipart
+content-type. This allows parts to be arranged in a
+tree structure, although this is a rare case as far
+as the Web is concerned.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_form_data">Form-data</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>In the normal case, when a form is submitted, the
+browser will use the <code>application/x-www-form-urlencoded</code>
+content-type. This type is just a list of keys and
+values and is therefore not fit for uploading files.</p></div>
+<div class="paragraph"><p>That’s where the <code>multipart/form-data</code> content-type
+comes in. When the form is configured to use this
+content-type, the browser will use one part of the
+message for each form field. This means that a file
+input field will be sent in its own part, but the
+same applies to all other kinds of fields.</p></div>
+<div class="paragraph"><p>A form with a text input, a file input and a select
+choice box will result in a multipart message with
+three parts, one for each field.</p></div>
+<div class="paragraph"><p>The browser does its best to determine the content-type
+of the files it sends this way, but you should not
+rely on it for determining the contents of the file.
+Proper investigation of the contents is recommended.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_checking_the_content_type">Checking the content-type</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>While there is a variety of multipart messages, the
+most common on the Web is <code>multipart/form-data</code>. It’s
+the type of message being sent when an HTML form
+allows uploading files.</p></div>
+<div class="paragraph"><p>You can quickly figure out if a multipart message
+has been sent by parsing the <code>content-type</code> header.</p></div>
+<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="color: #990000"><<</span><span style="color: #FF0000">"multipart"</span><span style="color: #990000">>></span>, <span style="color: #990000"><<</span><span style="color: #FF0000">"form-data"</span><span style="color: #990000">>></span>, <span style="color: #990000">_</span>}
+ <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:parse_header</span></span>(<span style="color: #990000"><<</span><span style="color: #FF0000">"content-type"</span><span style="color: #990000">>></span>, <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_reading_a_multipart_message">Reading a multipart message</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>To read a message you have to iterate over all its
+parts. Then, for each part, you can inspect its headers
+and read its body.</p></div>
+<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">multipart</span></span>(<span style="color: #009900">Req</span>) <span style="color: #990000">-></span>
+ <span style="font-weight: bold"><span style="color: #0000FF">case</span></span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:part</span></span>(<span style="color: #009900">Req</span>) <span style="font-weight: bold"><span style="color: #0000FF">of</span></span>
+ {<span style="color: #FF6600">ok</span>, <span style="color: #009900">_Headers</span>, <span style="color: #009900">Req2</span>} <span style="color: #990000">-></span>
+ {<span style="color: #FF6600">ok</span>, <span style="color: #009900">_Body</span>, <span style="color: #009900">Req3</span>} <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:part_body</span></span>(<span style="color: #009900">Req2</span>),
+ <span style="font-weight: bold"><span style="color: #000000">multipart</span></span>(<span style="color: #009900">Req3</span>);
+ {<span style="color: #FF6600">done</span>, <span style="color: #009900">Req2</span>} <span style="color: #990000">-></span>
+ <span style="color: #009900">Req2</span>
+ <span style="font-weight: bold"><span style="color: #0000FF">end</span></span><span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Parts do not have a size limit. When a part body is
+too big, Cowboy will return what it read so far and
+allow you to continue if you wish to do so.</p></div>
+<div class="paragraph"><p>The function <code>cow_multipart:form_data/1</code> can be used
+to quickly obtain information about a part from a
+<code>multipart/form-data</code> message. This function will
+tell you if the part is for a normal field or if it
+is a file being uploaded.</p></div>
+<div class="paragraph"><p>This can be used for example to allow large part bodies
+for files but crash when a normal field is too large.</p></div>
+<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">multipart</span></span>(<span style="color: #009900">Req</span>) <span style="color: #990000">-></span>
+ <span style="font-weight: bold"><span style="color: #0000FF">case</span></span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:part</span></span>(<span style="color: #009900">Req</span>) <span style="font-weight: bold"><span style="color: #0000FF">of</span></span>
+ {<span style="color: #FF6600">ok</span>, <span style="color: #009900">Headers</span>, <span style="color: #009900">Req2</span>} <span style="color: #990000">-></span>
+ <span style="color: #009900">Req4</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">case</span></span> <span style="font-weight: bold"><span style="color: #000000">cow_multipart:form_data</span></span>(<span style="color: #009900">Headers</span>) <span style="font-weight: bold"><span style="color: #0000FF">of</span></span>
+ {<span style="color: #FF6600">data</span>, <span style="color: #009900">_FieldName</span>} <span style="color: #990000">-></span>
+ {<span style="color: #FF6600">ok</span>, <span style="color: #009900">_Body</span>, <span style="color: #009900">Req3</span>} <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:part_body</span></span>(<span style="color: #009900">Req2</span>),
+ <span style="color: #009900">Req3</span>;
+ {<span style="color: #FF6600">file</span>, <span style="color: #009900">_FieldName</span>, <span style="color: #009900">_Filename</span>, <span style="color: #009900">_CType</span>, <span style="color: #009900">_CTransferEncoding</span>} <span style="color: #990000">-></span>
+ <span style="font-weight: bold"><span style="color: #000000">stream_file</span></span>(<span style="color: #009900">Req2</span>)
+ <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>,
+ <span style="font-weight: bold"><span style="color: #000000">multipart</span></span>(<span style="color: #009900">Req4</span>);
+ {<span style="color: #FF6600">done</span>, <span style="color: #009900">Req2</span>} <span style="color: #990000">-></span>
+ <span style="color: #009900">Req2</span>
+ <span style="font-weight: bold"><span style="color: #0000FF">end</span></span><span style="color: #990000">.</span>
+
+<span style="font-weight: bold"><span style="color: #000000">stream_file</span></span>(<span style="color: #009900">Req</span>) <span style="color: #990000">-></span>
+ <span style="font-weight: bold"><span style="color: #0000FF">case</span></span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:part_body</span></span>(<span style="color: #009900">Req</span>) <span style="font-weight: bold"><span style="color: #0000FF">of</span></span>
+ {<span style="color: #FF6600">ok</span>, <span style="color: #009900">_Body</span>, <span style="color: #009900">Req2</span>} <span style="color: #990000">-></span>
+ <span style="color: #009900">Req2</span>;
+ {<span style="color: #FF6600">more</span>, <span style="color: #009900">_Body</span>, <span style="color: #009900">Req2</span>} <span style="color: #990000">-></span>
+ <span style="font-weight: bold"><span style="color: #000000">stream_file</span></span>(<span style="color: #009900">Req2</span>)
+ <span style="font-weight: bold"><span style="color: #0000FF">end</span></span><span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>By default the body chunk Cowboy will return is limited
+to 8MB. This can of course be overriden. Both functions
+can take a second argument, the same list of options that
+will be passed to <code>cowboy_req:body/2</code> function.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_skipping_unwanted_parts">Skipping unwanted parts</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>If you do not want to read a part’s body, you can skip it.
+Skipping is easy. If you do not call the function to read
+the part’s body, Cowboy will automatically skip it when
+you request the next part.</p></div>
+<div class="paragraph"><p>The following snippet reads all part headers and skips
+all bodies:</p></div>
+<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">multipart</span></span>(<span style="color: #009900">Req</span>) <span style="color: #990000">-></span>
+ <span style="font-weight: bold"><span style="color: #0000FF">case</span></span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:part</span></span>(<span style="color: #009900">Req</span>) <span style="font-weight: bold"><span style="color: #0000FF">of</span></span>
+ {<span style="color: #FF6600">ok</span>, <span style="color: #009900">_Headers</span>, <span style="color: #009900">Req2</span>} <span style="color: #990000">-></span>
+ <span style="font-weight: bold"><span style="color: #000000">multipart</span></span>(<span style="color: #009900">Req2</span>);
+ {<span style="color: #FF6600">done</span>, <span style="color: #009900">Req2</span>} <span style="color: #990000">-></span>
+ <span style="color: #009900">Req2</span>
+ <span style="font-weight: bold"><span style="color: #0000FF">end</span></span><span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Similarly, if you start reading the body and it ends up
+being too big, you can simply continue with the next part,
+Cowboy will automatically skip what remains.</p></div>
+<div class="paragraph"><p>Note that the skipping rate may not be adequate for your
+application. If you observe poor performance when skipping,
+you might want to consider manually skipping by calling
+the <code>cowboy_req:part_body/1</code> function directly.</p></div>
+<div class="paragraph"><p>And if you started reading the message but decide that you
+do not need the remaining parts, you can simply stop reading
+entirely and Cowboy will automatically figure out what to do.</p></div>
+</div>
+</div>
+ + + +</div> + +<div class="span3 sidecol"> + + +<h3> + Cowboy + 2.0 + + User Guide +</h3> + +<ul> + + <li><a href="/docs/en/cowboy/2.0/guide">User Guide</a></li> + + + <li><a href="/docs/en/cowboy/2.0/manual">Function Reference</a></li> + + +</ul> + +<h4 id="docs-nav">Navigation</h4> + +<h4>Version select</h4> +<ul> + + + + <li><a href="/docs/en/cowboy/1.0/guide">1.0</a></li> + + <li><a href="/docs/en/cowboy/2.0/guide">2.0</a></li> + +</ul> + +</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 © Loïc Hoguin 2012-2016</p> + </div> + </div> + </div> + </footer> + + + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> + <script src="/js/bootstrap-carousel.js"></script> + <script src="/js/bootstrap-dropdown.js"></script> + <script src="/js/custom.js"></script> + </body> +</html> + + diff --git a/docs/en/cowboy/2.0/guide/overview.asciidoc b/docs/en/cowboy/2.0/guide/overview.asciidoc new file mode 100644 index 00000000..3e5cbb74 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/overview.asciidoc @@ -0,0 +1,150 @@ +[[overview]] +== Request overview + +This chapter explains the different steps a request +goes through until a response is sent, along with +details of the Cowboy implementation. + +=== Request/response + +As you already know, HTTP clients connect to the server and +send a request for a resource; the server then sends a +response containing the resource if it could obtain it. + +Before the server can send the resource, however, it +needs to perform many different operations to read the +request, find the resource, prepare the response being +sent and often other related operations the user can +add like writing logs. + +Requests take the following route in Cowboy: + +image::http_req_resp.png[HTTP request/response flowchart] + +This shows the default middlewares, but they may be +configured differently in your setup. The dark green +indicates the points where you can hook your own code, +the light green is the Cowboy code that you can of +course configure as needed. + +The `acceptor` is the part of the server that accepts +the connection and create an Erlang process to handle +it. The `parser` then starts reading from the socket +and handling requests as they come until the socket +is closed. + +A response may be sent at many different points in the +life of the request. If Cowboy can't parse the request, +it gives up with an error response. If the router can't +find the resource, it sends a not found error. Your +own code can of course send a response at any time. + +When a response is sent, you can optionally modify it +or act upon it by enabling the `onresponse` hook. By +default the response is sent directly to the client. + +=== And then? + +Behavior depends on what protocol is in use. + +HTTP/1.0 can only process one request per connection, +so Cowboy will close the connection immediately after +it sends the response. + +HTTP/1.1 allows the client to request that the server +keeps the connection alive. This mechanism is described +in the next section. + +HTTP/2 is designed to allow sending multiple requests +asynchronously on the same connection. Details on what +this means for your application is described in this +chapter. + +=== Keep-alive (HTTP/1.1) + +With HTTP/1.1, the connection may be left open for +subsequent requests to come. This mechanism is called +`keep-alive`. + +When the client sends a request to the server, it includes +a header indicating whether it would like to leave the +socket open. The server may or may not accept, indicating +its choice by sending the same header in the response. + +Cowboy will include this header automatically in all +responses to HTTP/1.1 requests. You can however force +the closing of the socket if you want. When Cowboy sees +you want to send a `connection: close` header, it will +not override it and will close the connection as soon +as the reply is sent. + +This snippet will force Cowboy to close the connection. + +[source,erlang] +---- +Req2 = cowboy_req:reply(200, [ + {<<"connection">>, <<"close">>}, +], <<"Closing the socket in 3.. 2.. 1..">>, Req). +---- + +Cowboy will only accept a certain number of new requests +on the same connection. By default it will run up to 100 +requests. This number can be changed by setting the +`max_keepalive` configuration value when starting an +HTTP listener. + +[source,erlang] +---- +cowboy:start_http(my_http_listener, 100, [{port, 8080}], [ + {env, [{dispatch, Dispatch}]}, + {max_keepalive, 5} +]). +---- + +Cowboy implements the keep-alive mechanism by reusing +the same process for all requests. This allows Cowboy +to save memory. This works well because most code will +not have any side effect impacting subsequent requests. +But it also means you need to clean up if you do have +code with side effects. The `terminate/3` function can +be used for this purpose. + +=== Pipelining (HTTP/1.1) + +While HTTP is designed as a sequential protocol, with +the client sending a request and then waiting for the +response from the server, nothing prevents the client +from sending more requests to the server without waiting +for the response, due to how sockets work. The server +still handles the requests sequentially and sends the +responses in the same order. + +This mechanism is called pipelining. It allows reducing +latency when a client needs to request many resources +at the same time. This is used by browsers when requesting +static files for example. + +This is handled automatically by the server. + +=== Asynchronous requests (HTTP/2) + +In HTTP/2, the client can send a request at any time. +And the server can send a response at any time too. + +This means for example that the client does not need +to wait for a request to be fully sent to send another, +it is possible to interleave a request with the request +body of another request. The same is true with responses. +Responses may also be sent in a different order. + +Because requests and responses are fully asynchronous, +Cowboy creates a new process for each request, and these +processes are managed by another process that handles the +connection itself. + +HTTP/2 servers may also decide to send resources to the +client before the client requests them. This is especially +useful for sending static files associated with the HTML +page requested, as this reduces the latency of the overall +response. Cowboy does not support this particular mechanism +at this point, however. diff --git a/docs/en/cowboy/2.0/guide/overview/index.html b/docs/en/cowboy/2.0/guide/overview/index.html new file mode 100644 index 00000000..70a191dd --- /dev/null +++ b/docs/en/cowboy/2.0/guide/overview/index.html @@ -0,0 +1,285 @@ +<!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"> + + <meta name="generator" content="Hugo 0.15" /> + + <title>Nine Nines: Request overview</title> + + <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'> + + <link href="/css/bootstrap.min.css" rel="stylesheet"> + <link href="/css/99s.css" 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="Keep in touch!" href="http://twitter.com/lhoguin"><img src="/img/ico_microblog.png" data-hover="/img/ico_microblog_alt.png"></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>Request overview</span></h1> + +<div class="paragraph"><p>This chapter explains the different steps a request
+goes through until a response is sent, along with
+details of the Cowboy implementation.</p></div>
+<div class="sect1">
+<h2 id="_request_response">Request/response</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>As you already know, HTTP clients connect to the server and
+send a request for a resource; the server then sends a
+response containing the resource if it could obtain it.</p></div>
+<div class="paragraph"><p>Before the server can send the resource, however, it
+needs to perform many different operations to read the
+request, find the resource, prepare the response being
+sent and often other related operations the user can
+add like writing logs.</p></div>
+<div class="paragraph"><p>Requests take the following route in Cowboy:</p></div>
+<div class="imageblock">
+<div class="content">
+<img src="../http_req_resp.png" alt="HTTP request/response flowchart" />
+</div>
+</div>
+<div class="paragraph"><p>This shows the default middlewares, but they may be
+configured differently in your setup. The dark green
+indicates the points where you can hook your own code,
+the light green is the Cowboy code that you can of
+course configure as needed.</p></div>
+<div class="paragraph"><p>The <code>acceptor</code> is the part of the server that accepts
+the connection and create an Erlang process to handle
+it. The <code>parser</code> then starts reading from the socket
+and handling requests as they come until the socket
+is closed.</p></div>
+<div class="paragraph"><p>A response may be sent at many different points in the
+life of the request. If Cowboy can’t parse the request,
+it gives up with an error response. If the router can’t
+find the resource, it sends a not found error. Your
+own code can of course send a response at any time.</p></div>
+<div class="paragraph"><p>When a response is sent, you can optionally modify it
+or act upon it by enabling the <code>onresponse</code> hook. By
+default the response is sent directly to the client.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_and_then">And then?</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Behavior depends on what protocol is in use.</p></div>
+<div class="paragraph"><p>HTTP/1.0 can only process one request per connection,
+so Cowboy will close the connection immediately after
+it sends the response.</p></div>
+<div class="paragraph"><p>HTTP/1.1 allows the client to request that the server
+keeps the connection alive. This mechanism is described
+in the next section.</p></div>
+<div class="paragraph"><p>HTTP/2 is designed to allow sending multiple requests
+asynchronously on the same connection. Details on what
+this means for your application is described in this
+chapter.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_keep_alive_http_1_1">Keep-alive (HTTP/1.1)</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>With HTTP/1.1, the connection may be left open for
+subsequent requests to come. This mechanism is called
+<code>keep-alive</code>.</p></div>
+<div class="paragraph"><p>When the client sends a request to the server, it includes
+a header indicating whether it would like to leave the
+socket open. The server may or may not accept, indicating
+its choice by sending the same header in the response.</p></div>
+<div class="paragraph"><p>Cowboy will include this header automatically in all
+responses to HTTP/1.1 requests. You can however force
+the closing of the socket if you want. When Cowboy sees
+you want to send a <code>connection: close</code> header, it will
+not override it and will close the connection as soon
+as the reply is sent.</p></div>
+<div class="paragraph"><p>This snippet will force Cowboy to close the connection.</p></div>
+<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="color: #009900">Req2</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:reply</span></span>(<span style="color: #993399">200</span>, [
+ {<span style="color: #990000"><<</span><span style="color: #FF0000">"connection"</span><span style="color: #990000">>></span>, <span style="color: #990000"><<</span><span style="color: #FF0000">"close"</span><span style="color: #990000">>></span>},
+], <span style="color: #990000"><<</span><span style="color: #FF0000">"Closing the socket in 3.. 2.. 1.."</span><span style="color: #990000">>></span>, <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Cowboy will only accept a certain number of new requests
+on the same connection. By default it will run up to 100
+requests. This number can be changed by setting the
+<code>max_keepalive</code> configuration value when starting an
+HTTP listener.</p></div>
+<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">cowboy:start_http</span></span>(<span style="color: #FF6600">my_http_listener</span>, <span style="color: #993399">100</span>, [{<span style="color: #FF6600">port</span>, <span style="color: #993399">8080</span>}], [
+ {<span style="color: #FF6600">env</span>, [{<span style="color: #FF6600">dispatch</span>, <span style="color: #009900">Dispatch</span>}]},
+ {<span style="color: #FF6600">max_keepalive</span>, <span style="color: #993399">5</span>}
+])<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Cowboy implements the keep-alive mechanism by reusing
+the same process for all requests. This allows Cowboy
+to save memory. This works well because most code will
+not have any side effect impacting subsequent requests.
+But it also means you need to clean up if you do have
+code with side effects. The <code>terminate/3</code> function can
+be used for this purpose.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_pipelining_http_1_1">Pipelining (HTTP/1.1)</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>While HTTP is designed as a sequential protocol, with
+the client sending a request and then waiting for the
+response from the server, nothing prevents the client
+from sending more requests to the server without waiting
+for the response, due to how sockets work. The server
+still handles the requests sequentially and sends the
+responses in the same order.</p></div>
+<div class="paragraph"><p>This mechanism is called pipelining. It allows reducing
+latency when a client needs to request many resources
+at the same time. This is used by browsers when requesting
+static files for example.</p></div>
+<div class="paragraph"><p>This is handled automatically by the server.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_asynchronous_requests_http_2">Asynchronous requests (HTTP/2)</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>In HTTP/2, the client can send a request at any time.
+And the server can send a response at any time too.</p></div>
+<div class="paragraph"><p>This means for example that the client does not need
+to wait for a request to be fully sent to send another,
+it is possible to interleave a request with the request
+body of another request. The same is true with responses.
+Responses may also be sent in a different order.</p></div>
+<div class="paragraph"><p>Because requests and responses are fully asynchronous,
+Cowboy creates a new process for each request, and these
+processes are managed by another process that handles the
+connection itself.</p></div>
+<div class="paragraph"><p>HTTP/2 servers may also decide to send resources to the
+client before the client requests them. This is especially
+useful for sending static files associated with the HTML
+page requested, as this reduces the latency of the overall
+response. Cowboy does not support this particular mechanism
+at this point, however.</p></div>
+</div>
+</div>
+ + + +</div> + +<div class="span3 sidecol"> + + +<h3> + Cowboy + 2.0 + + User Guide +</h3> + +<ul> + + <li><a href="/docs/en/cowboy/2.0/guide">User Guide</a></li> + + + <li><a href="/docs/en/cowboy/2.0/manual">Function Reference</a></li> + + +</ul> + +<h4 id="docs-nav">Navigation</h4> + +<h4>Version select</h4> +<ul> + + + + <li><a href="/docs/en/cowboy/1.0/guide">1.0</a></li> + + <li><a href="/docs/en/cowboy/2.0/guide">2.0</a></li> + +</ul> + +</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 © Loïc Hoguin 2012-2016</p> + </div> + </div> + </div> + </footer> + + + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> + <script src="/js/bootstrap-carousel.js"></script> + <script src="/js/bootstrap-dropdown.js"></script> + <script src="/js/custom.js"></script> + </body> +</html> + + diff --git a/docs/en/cowboy/2.0/guide/req.asciidoc b/docs/en/cowboy/2.0/guide/req.asciidoc new file mode 100644 index 00000000..09d442af --- /dev/null +++ b/docs/en/cowboy/2.0/guide/req.asciidoc @@ -0,0 +1,247 @@ +[[req]] +== The Req object + +The Req object is this variable that you will use to obtain +information about a request, read the body of the request +and send a response. + +=== A special variable + +While we call it an "object", it is not an object in the +OOP sense of the term. In fact it is completely opaque +to you and the only way you can perform operations using +it is by calling the functions from the `cowboy_req` +module. + +Almost all the calls to the `cowboy_req` module will +return an updated request object. Just like you would +keep the updated `State` variable in a gen_server, +you MUST keep the updated `Req` variable in a Cowboy +handler. Cowboy will use this object to know whether +a response has been sent when the handler has finished +executing. + +The Req object allows accessing both immutable and +mutable state. This means that calling some of the +functions twice will not produce the same result. +For example, when streaming the request body, the +function will return the body by chunks, one at a +time, until there is none left. + +=== Overview of the cowboy_req interface + +With the exception of functions manipulating the request +body, all functions return a single value. Depending on +the function this can be the requested value (method, +host, path, ...), a boolean (has_body, has_resp_header...) +a new Req object (set_resp_body, set_resp_header...), or +simply the atom `ok` (chunk, continue, ...). + +The request body reading functions may return `{Result, Req}` +or `{Result, Value, Req}`. The functions in this category +are `body/{1,2}`, `body_qs/{1,2}`, `part/{1,2}`, `part_body/{1,2}`. + +This chapter covers the access functions mainly. Cookies, +request body and response functions are covered in their +own chapters. + +=== Request + +When a client performs a request, it first sends a few required +values. They are sent differently depending on the protocol +being used, but the intent is the same. They indicate to the +server the type of action it wants to do and how to locate +the resource to perform it on. + +The method identifies the action. Standard methods include +GET, HEAD, OPTIONS, PATCH, POST, PUT, DELETE. Method names +are case sensitive. + +[source,erlang] +Method = cowboy_req:method(Req). + +The host, port and path parts of the URL identify the resource +being accessed. The host and port information may not be +available if the client uses HTTP/1.0. + +[source,erlang] +Host = cowboy_req:host(Req), +Port = cowboy_req:port(Req), +Path = cowboy_req:path(Req). + +The version used by the client can of course also be obtained. + +[source,erlang] +Version = cowboy_req:version(Req). + +Do note however that clients claiming to implement one version +of the protocol does not mean they implement it fully, or even +properly. + +=== Bindings + +After routing the request, bindings are available. Bindings +are these parts of the host or path that you chose to extract +when defining the routes of your application. + +You can fetch a single binding. The value will be `undefined` +if the binding doesn't exist. + +[source,erlang] +Binding = cowboy_req:binding(my_binding, Req). + +If you need a different value when the binding doesn't exist, +you can change the default. + +[source,erlang] +Binding = cowboy_req:binding(my_binding, Req, 42). + +You can also obtain all bindings in one call. They will be +returned as a list of key/value tuples. + +[source,erlang] +AllBindings = cowboy_req:bindings(Req). + +If you used `...` at the beginning of the route's pattern +for the host, you can retrieve the matched part of the host. +The value will be `undefined` otherwise. + +[source,erlang] +HostInfo = cowboy_req:host_info(Req). + +Similarly, if you used `...` at the end of the route's +pattern for the path, you can retrieve the matched part, +or get `undefined` otherwise. + +[source,erlang] +PathInfo = cowboy_req:path_info(Req). + +=== Query string + +The raw query string can be obtained directly. + +[source,erlang] +Qs = cowboy_req:qs(Req). + +You can parse the query string and then use standard library +functions to access individual values. + +[source,erlang] +QsVals = cowboy_req:parse_qs(Req), +{_, Lang} = lists:keyfind(<<"lang">>, 1, QsVals). + +You can match the query string into a map. + +[source,erlang] +#{id := ID, lang := Lang} = cowboy_req:match_qs([id, lang], Req). + +You can use constraints to validate the values while matching +them. The following snippet will crash if the `id` value is +not an integer number or if the `lang` value is empty. Additionally +the `id` value will be converted to an integer term, saving +you a conversion step. + +[source,erlang] +QsMap = cowboy_req:match_qs([{id, int}, {lang, nonempty}], Req). + +Note that in the case of duplicate query string keys, the map +value will become a list of the different values. + +Read more about ^constraints^. + +A default value can be provided. The default will be used +if the `lang` key is not found. It will not be used if +the key is found but has an empty value. + +[source,erlang] +#{lang := Lang} = cowboy_req:match_qs([{lang, [], <<"en-US">>}], Req). + +If no default is provided and the value is missing, the +query string is deemed invalid and the process will crash. + +=== Request URL + +You can reconstruct the full URL of the resource. + +[source,erlang] +URL = cowboy_req:url(Req). + +You can also obtain only the base of the URL, excluding the +path and query string. + +[source,erlang] +BaseURL = cowboy_req:host_url(Req). + +=== Headers + +Cowboy allows you to obtain the header values as string, +or parsed into a more meaningful representation. + +This will get the string value of a header. + +[source,erlang] +HeaderVal = cowboy_req:header(<<"content-type">>, Req). + +You can of course set a default in case the header is missing. + +[source,erlang] +HeaderVal = cowboy_req:header(<<"content-type">>, Req, <<"text/plain">>). + +And also obtain all headers. + +[source,erlang] +AllHeaders = cowboy_req:headers(Req). + +To parse the previous header, simply call `parse_header/{2,3}` +where you would call `header/{2,3}` otherwise. + +[source,erlang] +ParsedVal = cowboy_req:parse_header(<<"content-type">>, Req). + +Cowboy will crash if it doesn't know how to parse the given +header, or if the value is invalid. + +You can of course define a default value. Note that the default +value you specify here is the parsed value you'd like to get +by default. + +[source,erlang] +---- +ParsedVal = cowboy_req:parse_header(<<"content-type">>, Req, + {<<"text">>, <<"plain">>, []}). +---- + +The list of known headers and default values is defined in the +manual. + +=== Meta + +Cowboy will sometimes associate some meta information with +the request. Built-in meta values are listed in the manual +for their respective modules. + +This will get a meta value. The returned value will be `undefined` +if it isn't defined. + +[source,erlang] +MetaVal = cowboy_req:meta(websocket_version, Req). + +You can change the default value if needed. + +[source,erlang] +MetaVal = cowboy_req:meta(websocket_version, Req, 13). + +You can also define your own meta values. The name must be +an `atom()`. + +[source,erlang] +Req2 = cowboy_req:set_meta(the_answer, 42, Req). + +=== Peer + +You can obtain the peer address and port number. This is +not necessarily the actual IP and port of the client, but +rather the one of the machine that connected to the server. + +[source,erlang] +{IP, Port} = cowboy_req:peer(Req). diff --git a/docs/en/cowboy/2.0/guide/req/index.html b/docs/en/cowboy/2.0/guide/req/index.html new file mode 100644 index 00000000..c3442c64 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/req/index.html @@ -0,0 +1,443 @@ +<!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"> + + <meta name="generator" content="Hugo 0.15" /> + + <title>Nine Nines: The Req object</title> + + <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'> + + <link href="/css/bootstrap.min.css" rel="stylesheet"> + <link href="/css/99s.css" 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="Keep in touch!" href="http://twitter.com/lhoguin"><img src="/img/ico_microblog.png" data-hover="/img/ico_microblog_alt.png"></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>The Req object</span></h1> + +<div class="paragraph"><p>The Req object is this variable that you will use to obtain
+information about a request, read the body of the request
+and send a response.</p></div>
+<div class="sect1">
+<h2 id="_a_special_variable">A special variable</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>While we call it an "object", it is not an object in the
+OOP sense of the term. In fact it is completely opaque
+to you and the only way you can perform operations using
+it is by calling the functions from the <code>cowboy_req</code>
+module.</p></div>
+<div class="paragraph"><p>Almost all the calls to the <code>cowboy_req</code> module will
+return an updated request object. Just like you would
+keep the updated <code>State</code> variable in a gen_server,
+you MUST keep the updated <code>Req</code> variable in a Cowboy
+handler. Cowboy will use this object to know whether
+a response has been sent when the handler has finished
+executing.</p></div>
+<div class="paragraph"><p>The Req object allows accessing both immutable and
+mutable state. This means that calling some of the
+functions twice will not produce the same result.
+For example, when streaming the request body, the
+function will return the body by chunks, one at a
+time, until there is none left.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_overview_of_the_cowboy_req_interface">Overview of the cowboy_req interface</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>With the exception of functions manipulating the request
+body, all functions return a single value. Depending on
+the function this can be the requested value (method,
+host, path, …), a boolean (has_body, has_resp_header…)
+a new Req object (set_resp_body, set_resp_header…), or
+simply the atom <code>ok</code> (chunk, continue, …).</p></div>
+<div class="paragraph"><p>The request body reading functions may return <code>{Result, Req}</code>
+or <code>{Result, Value, Req}</code>. The functions in this category
+are <code>body/{1,2}</code>, <code>body_qs/{1,2}</code>, <code>part/{1,2}</code>, <code>part_body/{1,2}</code>.</p></div>
+<div class="paragraph"><p>This chapter covers the access functions mainly. Cookies,
+request body and response functions are covered in their
+own chapters.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_request">Request</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>When a client performs a request, it first sends a few required
+values. They are sent differently depending on the protocol
+being used, but the intent is the same. They indicate to the
+server the type of action it wants to do and how to locate
+the resource to perform it on.</p></div>
+<div class="paragraph"><p>The method identifies the action. Standard methods include
+GET, HEAD, OPTIONS, PATCH, POST, PUT, DELETE. Method names
+are case sensitive.</p></div>
+<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="color: #009900">Method</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:method</span></span>(<span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>The host, port and path parts of the URL identify the resource
+being accessed. The host and port information may not be
+available if the client uses HTTP/1.0.</p></div>
+<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="color: #009900">Host</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:host</span></span>(<span style="color: #009900">Req</span>),
+<span style="color: #009900">Port</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:port</span></span>(<span style="color: #009900">Req</span>),
+<span style="color: #009900">Path</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:path</span></span>(<span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>The version used by the client can of course also be obtained.</p></div>
+<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="color: #009900">Version</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:version</span></span>(<span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Do note however that clients claiming to implement one version
+of the protocol does not mean they implement it fully, or even
+properly.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_bindings">Bindings</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>After routing the request, bindings are available. Bindings
+are these parts of the host or path that you chose to extract
+when defining the routes of your application.</p></div>
+<div class="paragraph"><p>You can fetch a single binding. The value will be <code>undefined</code>
+if the binding doesn’t exist.</p></div>
+<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="color: #009900">Binding</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:binding</span></span>(<span style="color: #FF6600">my_binding</span>, <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>If you need a different value when the binding doesn’t exist,
+you can change the default.</p></div>
+<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="color: #009900">Binding</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:binding</span></span>(<span style="color: #FF6600">my_binding</span>, <span style="color: #009900">Req</span>, <span style="color: #993399">42</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>You can also obtain all bindings in one call. They will be
+returned as a list of key/value tuples.</p></div>
+<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="color: #009900">AllBindings</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:bindings</span></span>(<span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>If you used <code>...</code> at the beginning of the route’s pattern
+for the host, you can retrieve the matched part of the host.
+The value will be <code>undefined</code> otherwise.</p></div>
+<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="color: #009900">HostInfo</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:host_info</span></span>(<span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Similarly, if you used <code>...</code> at the end of the route’s
+pattern for the path, you can retrieve the matched part,
+or get <code>undefined</code> otherwise.</p></div>
+<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="color: #009900">PathInfo</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:path_info</span></span>(<span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_query_string">Query string</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>The raw query string can be obtained directly.</p></div>
+<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="color: #009900">Qs</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:qs</span></span>(<span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>You can parse the query string and then use standard library
+functions to access individual values.</p></div>
+<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="color: #009900">QsVals</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:parse_qs</span></span>(<span style="color: #009900">Req</span>),
+{<span style="color: #990000">_</span>, <span style="color: #009900">Lang</span>} <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">lists:keyfind</span></span>(<span style="color: #990000"><<</span><span style="color: #FF0000">"lang"</span><span style="color: #990000">>></span>, <span style="color: #993399">1</span>, <span style="color: #009900">QsVals</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>You can match the query string into a map.</p></div>
+<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="color: #FF6600">id</span> <span style="color: #990000">:=</span> <span style="color: #009900">ID</span>, <span style="color: #FF6600">lang</span> <span style="color: #990000">:=</span> <span style="color: #009900">Lang</span>} <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:match_qs</span></span>([<span style="color: #FF6600">id</span>, <span style="color: #FF6600">lang</span>], <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>You can use constraints to validate the values while matching
+them. The following snippet will crash if the <code>id</code> value is
+not an integer number or if the <code>lang</code> value is empty. Additionally
+the <code>id</code> value will be converted to an integer term, saving
+you a conversion step.</p></div>
+<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="color: #009900">QsMap</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:match_qs</span></span>([{<span style="color: #FF6600">id</span>, <span style="color: #FF6600">int</span>}, {<span style="color: #FF6600">lang</span>, <span style="color: #FF6600">nonempty</span>}], <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Note that in the case of duplicate query string keys, the map
+value will become a list of the different values.</p></div>
+<div class="paragraph"><p>Read more about <sup>constraints</sup>.</p></div>
+<div class="paragraph"><p>A default value can be provided. The default will be used
+if the <code>lang</code> key is not found. It will not be used if
+the key is found but has an empty value.</p></div>
+<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="color: #FF6600">lang</span> <span style="color: #990000">:=</span> <span style="color: #009900">Lang</span>} <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:match_qs</span></span>([{<span style="color: #FF6600">lang</span>, [], <span style="color: #990000"><<</span><span style="color: #FF0000">"en-US"</span><span style="color: #990000">>></span>}], <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>If no default is provided and the value is missing, the
+query string is deemed invalid and the process will crash.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_request_url">Request URL</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>You can reconstruct the full URL of the resource.</p></div>
+<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="color: #009900">URL</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:url</span></span>(<span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>You can also obtain only the base of the URL, excluding the
+path and query string.</p></div>
+<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="color: #009900">BaseURL</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:host_url</span></span>(<span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_headers">Headers</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Cowboy allows you to obtain the header values as string,
+or parsed into a more meaningful representation.</p></div>
+<div class="paragraph"><p>This will get the string value of a header.</p></div>
+<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="color: #009900">HeaderVal</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:header</span></span>(<span style="color: #990000"><<</span><span style="color: #FF0000">"content-type"</span><span style="color: #990000">>></span>, <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>You can of course set a default in case the header is missing.</p></div>
+<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="color: #009900">HeaderVal</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:header</span></span>(<span style="color: #990000"><<</span><span style="color: #FF0000">"content-type"</span><span style="color: #990000">>></span>, <span style="color: #009900">Req</span>, <span style="color: #990000"><<</span><span style="color: #FF0000">"text/plain"</span><span style="color: #990000">>></span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>And also obtain all headers.</p></div>
+<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="color: #009900">AllHeaders</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:headers</span></span>(<span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>To parse the previous header, simply call <code>parse_header/{2,3}</code>
+where you would call <code>header/{2,3}</code> otherwise.</p></div>
+<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="color: #009900">ParsedVal</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:parse_header</span></span>(<span style="color: #990000"><<</span><span style="color: #FF0000">"content-type"</span><span style="color: #990000">>></span>, <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Cowboy will crash if it doesn’t know how to parse the given
+header, or if the value is invalid.</p></div>
+<div class="paragraph"><p>You can of course define a default value. Note that the default
+value you specify here is the parsed value you’d like to get
+by default.</p></div>
+<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="color: #009900">ParsedVal</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:parse_header</span></span>(<span style="color: #990000"><<</span><span style="color: #FF0000">"content-type"</span><span style="color: #990000">>></span>, <span style="color: #009900">Req</span>,
+ {<span style="color: #990000"><<</span><span style="color: #FF0000">"text"</span><span style="color: #990000">>></span>, <span style="color: #990000"><<</span><span style="color: #FF0000">"plain"</span><span style="color: #990000">>></span>, []})<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>The list of known headers and default values is defined in the
+manual.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_meta">Meta</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Cowboy will sometimes associate some meta information with
+the request. Built-in meta values are listed in the manual
+for their respective modules.</p></div>
+<div class="paragraph"><p>This will get a meta value. The returned value will be <code>undefined</code>
+if it isn’t defined.</p></div>
+<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="color: #009900">MetaVal</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:meta</span></span>(<span style="color: #FF6600">websocket_version</span>, <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>You can change the default value if needed.</p></div>
+<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="color: #009900">MetaVal</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:meta</span></span>(<span style="color: #FF6600">websocket_version</span>, <span style="color: #009900">Req</span>, <span style="color: #993399">13</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>You can also define your own meta values. The name must be
+an <code>atom()</code>.</p></div>
+<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="color: #009900">Req2</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:set_meta</span></span>(<span style="color: #FF6600">the_answer</span>, <span style="color: #993399">42</span>, <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_peer">Peer</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>You can obtain the peer address and port number. This is
+not necessarily the actual IP and port of the client, but
+rather the one of the machine that connected to the server.</p></div>
+<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="color: #009900">IP</span>, <span style="color: #009900">Port</span>} <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:peer</span></span>(<span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+</div>
+</div>
+ + + +</div> + +<div class="span3 sidecol"> + + +<h3> + Cowboy + 2.0 + + User Guide +</h3> + +<ul> + + <li><a href="/docs/en/cowboy/2.0/guide">User Guide</a></li> + + + <li><a href="/docs/en/cowboy/2.0/manual">Function Reference</a></li> + + +</ul> + +<h4 id="docs-nav">Navigation</h4> + +<h4>Version select</h4> +<ul> + + + + <li><a href="/docs/en/cowboy/1.0/guide">1.0</a></li> + + <li><a href="/docs/en/cowboy/2.0/guide">2.0</a></li> + +</ul> + +</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 © Loïc Hoguin 2012-2016</p> + </div> + </div> + </div> + </footer> + + + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> + <script src="/js/bootstrap-carousel.js"></script> + <script src="/js/bootstrap-dropdown.js"></script> + <script src="/js/custom.js"></script> + </body> +</html> + + diff --git a/docs/en/cowboy/2.0/guide/req_body.asciidoc b/docs/en/cowboy/2.0/guide/req_body.asciidoc new file mode 100644 index 00000000..d2a43d24 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/req_body.asciidoc @@ -0,0 +1,152 @@ +[[req_body]] +== Reading the request body + +The Req object also allows you to read the request body. + +Because the request body can be of any size, all body +reading operations will only work once, as Cowboy will +not cache the result of these operations. + +Cowboy will not attempt to read the body until you do. +If handler execution ends without reading it, Cowboy +will simply skip it. + +Cowboy provides different ways to read the request body. +You can read it directly, stream it, but also read and +parse in a single call for form urlencoded formats or +multipart. All of these except multipart are covered in +this chapter. Multipart is covered later on in the guide. + +=== Check for request body + +You can check whether a body was sent with the request. + +[source,erlang] +cowboy_req:has_body(Req). + +It will return `true` if there is a request body, and +`false` otherwise. + +Note that it is generally safe to assume that a body is +sent for `POST`, `PUT` and `PATCH` requests, without +having to explicitly check for it. + +=== Request body length + +You can obtain the body length if it was sent with the +request. + +[source,erlang] +Length = cowboy_req:body_length(Req). + +The value returned will be `undefined` if the length +couldn't be figured out from the request headers. If +there's a body but no length is given, this means that +the chunked transfer-encoding was used. You can read +chunked bodies by using the stream functions. + +=== Reading the body + +You can read the whole body directly in one call. + +[source,erlang] +{ok, Body, Req2} = cowboy_req:body(Req). + +By default, Cowboy will attempt to read up to a +size of 8MB. You can override this limit as needed. + +[source,erlang] +{ok, Body, Req2} = cowboy_req:body(Req, [{length, 100000000}]). + +You can also disable it. + +[source,erlang] +{ok, Body, Req2} = cowboy_req:body(Req, [{length, infinity}]). + +It is recommended that you do not disable it for public +facing websites. + +If the body is larger than the limit, then Cowboy will return +a `more` tuple instead, allowing you to stream it if you +would like to. + +=== Streaming the body + +You can stream the request body by chunks. + +Cowboy returns a `more` tuple when there is more body to +be read, and an `ok` tuple for the last chunk. This allows +you to loop over all chunks. + +[source,erlang] +---- +body_to_console(Req) -> + case cowboy_req:body(Req) of + {ok, Data, Req2} -> + io:format("~s", [Data]), + Req2; + {more, Data, Req2} -> + io:format("~s", [Data]), + body_to_console(Req2) + end. +---- + +You can of course set the `length` option to configure the +size of chunks. + +=== Rate of data transmission + +You can control the rate of data transmission by setting +options when calling body functions. This applies not only +to the functions described in this chapter, but also to +the multipart functions. + +The `read_length` option defines the maximum amount of data +to be received from the socket at once, in bytes. + +The `read_timeout` option defines the time Cowboy waits +before that amount is received, in milliseconds. + +=== Transfer and content decoding + +Cowboy will by default decode the chunked transfer-encoding +if any. It will not decode any content-encoding by default. + +The first time you call a body function you can set the +`transfer_decode` and `content_decode` options. If the body +was already started being read these options are simply +ignored. + +The following example shows how to set both options. + +[source,erlang] +---- +{ok, Data, Req2} = cowboy_req:body(Req, [ + {transfer_decode, fun transfer_decode/2, TransferState}, + {content_decode, fun content_decode/1} +]). +---- + +=== Reading a form urlencoded body + +You can directly obtain a list of key/value pairs if the +body was sent using the application/x-www-form-urlencoded +content-type. + +[source,erlang] +{ok, KeyValues, Req2} = cowboy_req:body_qs(Req). + +You can then retrieve an individual value from that list. + +[source,erlang] +{_, Lang} = lists:keyfind(lang, 1, KeyValues). + +You should not attempt to match on the list as the order +of the values is undefined. + +By default Cowboy will reject bodies with a size above +64KB when using this function. You can override this limit +by setting the `length` option. + +[source,erlang] +{ok, KeyValues, Req2} = cowboy_req:body_qs(Req, [{length, 2000000}]). diff --git a/docs/en/cowboy/2.0/guide/req_body/index.html b/docs/en/cowboy/2.0/guide/req_body/index.html new file mode 100644 index 00000000..ac43be1d --- /dev/null +++ b/docs/en/cowboy/2.0/guide/req_body/index.html @@ -0,0 +1,312 @@ +<!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"> + + <meta name="generator" content="Hugo 0.15" /> + + <title>Nine Nines: Reading the request body</title> + + <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'> + + <link href="/css/bootstrap.min.css" rel="stylesheet"> + <link href="/css/99s.css" 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="Keep in touch!" href="http://twitter.com/lhoguin"><img src="/img/ico_microblog.png" data-hover="/img/ico_microblog_alt.png"></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>Reading the request body</span></h1> + +<div class="paragraph"><p>The Req object also allows you to read the request body.</p></div>
+<div class="paragraph"><p>Because the request body can be of any size, all body
+reading operations will only work once, as Cowboy will
+not cache the result of these operations.</p></div>
+<div class="paragraph"><p>Cowboy will not attempt to read the body until you do.
+If handler execution ends without reading it, Cowboy
+will simply skip it.</p></div>
+<div class="paragraph"><p>Cowboy provides different ways to read the request body.
+You can read it directly, stream it, but also read and
+parse in a single call for form urlencoded formats or
+multipart. All of these except multipart are covered in
+this chapter. Multipart is covered later on in the guide.</p></div>
+<div class="sect1">
+<h2 id="_check_for_request_body">Check for request body</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>You can check whether a body was sent with the request.</p></div>
+<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">cowboy_req:has_body</span></span>(<span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>It will return <code>true</code> if there is a request body, and
+<code>false</code> otherwise.</p></div>
+<div class="paragraph"><p>Note that it is generally safe to assume that a body is
+sent for <code>POST</code>, <code>PUT</code> and <code>PATCH</code> requests, without
+having to explicitly check for it.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_request_body_length">Request body length</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>You can obtain the body length if it was sent with the
+request.</p></div>
+<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="color: #009900">Length</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:body_length</span></span>(<span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>The value returned will be <code>undefined</code> if the length
+couldn’t be figured out from the request headers. If
+there’s a body but no length is given, this means that
+the chunked transfer-encoding was used. You can read
+chunked bodies by using the stream functions.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_reading_the_body">Reading the body</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>You can read the whole body directly in one call.</p></div>
+<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="color: #FF6600">ok</span>, <span style="color: #009900">Body</span>, <span style="color: #009900">Req2</span>} <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:body</span></span>(<span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>By default, Cowboy will attempt to read up to a
+size of 8MB. You can override this limit as needed.</p></div>
+<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="color: #FF6600">ok</span>, <span style="color: #009900">Body</span>, <span style="color: #009900">Req2</span>} <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:body</span></span>(<span style="color: #009900">Req</span>, [{<span style="font-weight: bold"><span style="color: #000080">length</span></span>, <span style="color: #993399">100000000</span>}])<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>You can also disable it.</p></div>
+<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="color: #FF6600">ok</span>, <span style="color: #009900">Body</span>, <span style="color: #009900">Req2</span>} <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:body</span></span>(<span style="color: #009900">Req</span>, [{<span style="font-weight: bold"><span style="color: #000080">length</span></span>, <span style="color: #FF6600">infinity</span>}])<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>It is recommended that you do not disable it for public
+facing websites.</p></div>
+<div class="paragraph"><p>If the body is larger than the limit, then Cowboy will return
+a <code>more</code> tuple instead, allowing you to stream it if you
+would like to.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_streaming_the_body">Streaming the body</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>You can stream the request body by chunks.</p></div>
+<div class="paragraph"><p>Cowboy returns a <code>more</code> tuple when there is more body to
+be read, and an <code>ok</code> tuple for the last chunk. This allows
+you to loop over all chunks.</p></div>
+<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">body_to_console</span></span>(<span style="color: #009900">Req</span>) <span style="color: #990000">-></span>
+ <span style="font-weight: bold"><span style="color: #0000FF">case</span></span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:body</span></span>(<span style="color: #009900">Req</span>) <span style="font-weight: bold"><span style="color: #0000FF">of</span></span>
+ {<span style="color: #FF6600">ok</span>, <span style="color: #009900">Data</span>, <span style="color: #009900">Req2</span>} <span style="color: #990000">-></span>
+ <span style="font-weight: bold"><span style="color: #000000">io:format</span></span>(<span style="color: #FF0000">"~s"</span>, [<span style="color: #009900">Data</span>]),
+ <span style="color: #009900">Req2</span>;
+ {<span style="color: #FF6600">more</span>, <span style="color: #009900">Data</span>, <span style="color: #009900">Req2</span>} <span style="color: #990000">-></span>
+ <span style="font-weight: bold"><span style="color: #000000">io:format</span></span>(<span style="color: #FF0000">"~s"</span>, [<span style="color: #009900">Data</span>]),
+ <span style="font-weight: bold"><span style="color: #000000">body_to_console</span></span>(<span style="color: #009900">Req2</span>)
+ <span style="font-weight: bold"><span style="color: #0000FF">end</span></span><span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>You can of course set the <code>length</code> option to configure the
+size of chunks.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_rate_of_data_transmission">Rate of data transmission</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>You can control the rate of data transmission by setting
+options when calling body functions. This applies not only
+to the functions described in this chapter, but also to
+the multipart functions.</p></div>
+<div class="paragraph"><p>The <code>read_length</code> option defines the maximum amount of data
+to be received from the socket at once, in bytes.</p></div>
+<div class="paragraph"><p>The <code>read_timeout</code> option defines the time Cowboy waits
+before that amount is received, in milliseconds.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_transfer_and_content_decoding">Transfer and content decoding</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Cowboy will by default decode the chunked transfer-encoding
+if any. It will not decode any content-encoding by default.</p></div>
+<div class="paragraph"><p>The first time you call a body function you can set the
+<code>transfer_decode</code> and <code>content_decode</code> options. If the body
+was already started being read these options are simply
+ignored.</p></div>
+<div class="paragraph"><p>The following example shows how to set both options.</p></div>
+<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="color: #FF6600">ok</span>, <span style="color: #009900">Data</span>, <span style="color: #009900">Req2</span>} <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:body</span></span>(<span style="color: #009900">Req</span>, [
+ {<span style="color: #FF6600">transfer_decode</span>, <span style="font-weight: bold"><span style="color: #0000FF">fun</span></span> <span style="font-weight: bold"><span style="color: #000000">transfer_decode</span></span><span style="color: #990000">/</span><span style="color: #993399">2</span>, <span style="color: #009900">TransferState</span>},
+ {<span style="color: #FF6600">content_decode</span>, <span style="font-weight: bold"><span style="color: #0000FF">fun</span></span> <span style="font-weight: bold"><span style="color: #000000">content_decode</span></span><span style="color: #990000">/</span><span style="color: #993399">1</span>}
+])<span style="color: #990000">.</span></tt></pre></div></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_reading_a_form_urlencoded_body">Reading a form urlencoded body</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>You can directly obtain a list of key/value pairs if the
+body was sent using the application/x-www-form-urlencoded
+content-type.</p></div>
+<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="color: #FF6600">ok</span>, <span style="color: #009900">KeyValues</span>, <span style="color: #009900">Req2</span>} <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:body_qs</span></span>(<span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>You can then retrieve an individual value from that list.</p></div>
+<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="color: #990000">_</span>, <span style="color: #009900">Lang</span>} <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">lists:keyfind</span></span>(<span style="color: #FF6600">lang</span>, <span style="color: #993399">1</span>, <span style="color: #009900">KeyValues</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>You should not attempt to match on the list as the order
+of the values is undefined.</p></div>
+<div class="paragraph"><p>By default Cowboy will reject bodies with a size above
+64KB when using this function. You can override this limit
+by setting the <code>length</code> option.</p></div>
+<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="color: #FF6600">ok</span>, <span style="color: #009900">KeyValues</span>, <span style="color: #009900">Req2</span>} <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:body_qs</span></span>(<span style="color: #009900">Req</span>, [{<span style="font-weight: bold"><span style="color: #000080">length</span></span>, <span style="color: #993399">2000000</span>}])<span style="color: #990000">.</span></tt></pre></div></div>
+</div>
+</div>
+ + + +</div> + +<div class="span3 sidecol"> + + +<h3> + Cowboy + 2.0 + + User Guide +</h3> + +<ul> + + <li><a href="/docs/en/cowboy/2.0/guide">User Guide</a></li> + + + <li><a href="/docs/en/cowboy/2.0/manual">Function Reference</a></li> + + +</ul> + +<h4 id="docs-nav">Navigation</h4> + +<h4>Version select</h4> +<ul> + + + + <li><a href="/docs/en/cowboy/1.0/guide">1.0</a></li> + + <li><a href="/docs/en/cowboy/2.0/guide">2.0</a></li> + +</ul> + +</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 © Loïc Hoguin 2012-2016</p> + </div> + </div> + </div> + </footer> + + + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> + <script src="/js/bootstrap-carousel.js"></script> + <script src="/js/bootstrap-dropdown.js"></script> + <script src="/js/custom.js"></script> + </body> +</html> + + diff --git a/docs/en/cowboy/2.0/guide/resource_design.asciidoc b/docs/en/cowboy/2.0/guide/resource_design.asciidoc new file mode 100644 index 00000000..691953f1 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/resource_design.asciidoc @@ -0,0 +1,221 @@ +[[resource_design]] +== Designing a resource handler + +This chapter aims to provide you with a list of questions +you must answer in order to write a good resource handler. +It is meant to be usable as a step by step guide. + +=== The service + +Can the service become unavailable, and when it does, can +we detect it? For example, database connectivity problems +may be detected early. We may also have planned outages +of all or parts of the system. Implement the +`service_available` callback. + +What HTTP methods does the service implement? Do we need +more than the standard OPTIONS, HEAD, GET, PUT, POST, +PATCH and DELETE? Are we not using one of those at all? +Implement the `known_methods` callback. + +=== Type of resource handler + +Am I writing a handler for a collection of resources, +or for a single resource? + +The semantics for each of these are quite different. +You should not mix collection and single resource in +the same handler. + +=== Collection handler + +Skip this section if you are not doing a collection. + +Is the collection hardcoded or dynamic? For example, +if you use the route `/users` for the collection of +users then the collection is hardcoded; if you use +`/forums/:category` for the collection of threads +then it isn't. When the collection is hardcoded you +can safely assume the resource always exists. + +What methods should I implement? + +OPTIONS is used to get some information about the +collection. It is recommended to allow it even if you +do not implement it, as Cowboy has a default +implementation built-in. + +HEAD and GET are used to retrieve the collection. +If you allow GET, also allow HEAD as there's no extra +work required to make it work. + +POST is used to create a new resource inside the +collection. Creating a resource by using POST on +the collection is useful when resources may be +created before knowing their URI, usually because +parts of it are generated dynamically. A common +case is some kind of auto incremented integer +identifier. + +The next methods are more rarely allowed. + +PUT is used to create a new collection (when +the collection isn't hardcoded), or replace +the entire collection. + +DELETE is used to delete the entire collection. + +PATCH is used to modify the collection using +instructions given in the request body. A PATCH +operation is atomic. The PATCH operation may +be used for such things as reordering; adding, +modifying or deleting parts of the collection. + +=== Single resource handler + +Skip this section if you are doing a collection. + +What methods should I implement? + +OPTIONS is used to get some information about the +resource. It is recommended to allow it even if you +do not implement it, as Cowboy has a default +implementation built-in. + +HEAD and GET are used to retrieve the resource. +If you allow GET, also allow HEAD as there's no extra +work required to make it work. + +POST is used to update the resource. + +PUT is used to create a new resource (when it doesn't +already exist) or replace the resource. + +DELETE is used to delete the resource. + +PATCH is used to modify the resource using +instructions given in the request body. A PATCH +operation is atomic. The PATCH operation may +be used for adding, removing or modifying specific +values in the resource. + +=== The resource + +Following the above discussion, implement the +`allowed_methods` callback. + +Does the resource always exist? If it may not, implement +the `resource_exists` callback. + +Do I need to authenticate the client before they can +access the resource? What authentication mechanisms +should I provide? This may include form-based, token-based +(in the URL or a cookie), HTTP basic, HTTP digest, +SSL certificate or any other form of authentication. +Implement the `is_authorized` callback. + +Do I need fine-grained access control? How do I determine +that they are authorized access? Handle that in your +`is_authorized` callback. + +Can access to a resource be forbidden regardless of access +being authorized? A simple example of that is censorship +of a resource. Implement the `forbidden` callback. + +Are there any constraints on the length of the resource URI? +For example, the URI may be used as a key in storage and may +have a limit in length. Implement `uri_too_long`. + +=== Representations + +What media types do I provide? If text based, what charsets +are provided? What languages do I provide? + +Implement the mandatory `content_types_provided`. Prefix +the callbacks with `to_` for clarity. For example, `to_html` +or `to_text`. + +Implement the `languages_provided` or `charsets_provided` +callbacks if applicable. + +Is there any other header that may make the representation +of the resource vary? Implement the `variances` callback. + +Depending on your choices for caching content, you may +want to implement one or more of the `generate_etag`, +`last_modified` and `expires` callbacks. + +Do I want the user or user agent to actively choose a +representation available? Send a list of available +representations in the response body and implement +the `multiple_choices` callback. + +=== Redirections + +Do I need to keep track of what resources were deleted? +For example, you may have a mechanism where moving a +resource leaves a redirect link to its new location. +Implement the `previously_existed` callback. + +Was the resource moved, and is the move temporary? If +it is explicitly temporary, for example due to maintenance, +implement the `moved_temporarily` callback. Otherwise, +implement the `moved_permanently` callback. + +=== The request + +Do we need to perform extra checks to make sure the request +is valid? Cowboy will do many checks when receiving the +request already, do we need more? Note that this only +applies to the request-line and headers of the request, +and not the body. Implement `malformed_request`. + +May there be a request body? Will I know its size? +What's the maximum size of the request body I'm willing +to accept? Implement `valid_entity_length`. + +Finally, take a look at the sections corresponding to the +methods you are implementing. + +=== OPTIONS method + +Cowboy by default will send back a list of allowed methods. +Do I need to add more information to the response? Implement +the `options` method. + +=== GET and HEAD methods + +If you implement the methods GET and/or HEAD, you must +implement one `ProvideResource` callback for each +content-type returned by the `content_types_provided` +callback. + +=== PUT, POST and PATCH methods + +If you implement the methods PUT, POST and/or PATCH, +you must implement the `content_types_accepted` callback, +and one `AcceptResource` callback for each content-type +it returns. Prefix the `AcceptResource` callback names +with `from_` for clarity. For example, `from_html` or +`from_json`. + +Do we want to allow the POST method to create individual +resources directly through their URI (like PUT)? Implement +the `allow_missing_post` callback. It is recommended to +explicitly use PUT in these cases instead. + +May there be conflicts when using PUT to create or replace +a resource? Do we want to make sure that two updates around +the same time are not cancelling one another? Implement the +`is_conflict` callback. + +=== DELETE methods + +If you implement the method DELETE, you must implement +the `delete_resource` callback. + +When `delete_resource` returns, is the resource completely +removed from the server, including from any caching service? +If not, and/or if the deletion is asynchronous and we have +no way of knowing it has been completed yet, implement the +`delete_completed` callback. diff --git a/docs/en/cowboy/2.0/guide/resource_design/index.html b/docs/en/cowboy/2.0/guide/resource_design/index.html new file mode 100644 index 00000000..94d6307e --- /dev/null +++ b/docs/en/cowboy/2.0/guide/resource_design/index.html @@ -0,0 +1,350 @@ +<!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"> + + <meta name="generator" content="Hugo 0.15" /> + + <title>Nine Nines: Designing a resource handler</title> + + <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'> + + <link href="/css/bootstrap.min.css" rel="stylesheet"> + <link href="/css/99s.css" 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="Keep in touch!" href="http://twitter.com/lhoguin"><img src="/img/ico_microblog.png" data-hover="/img/ico_microblog_alt.png"></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>Designing a resource handler</span></h1> + +<div class="paragraph"><p>This chapter aims to provide you with a list of questions
+you must answer in order to write a good resource handler.
+It is meant to be usable as a step by step guide.</p></div>
+<div class="sect1">
+<h2 id="_the_service">The service</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Can the service become unavailable, and when it does, can
+we detect it? For example, database connectivity problems
+may be detected early. We may also have planned outages
+of all or parts of the system. Implement the
+<code>service_available</code> callback.</p></div>
+<div class="paragraph"><p>What HTTP methods does the service implement? Do we need
+more than the standard OPTIONS, HEAD, GET, PUT, POST,
+PATCH and DELETE? Are we not using one of those at all?
+Implement the <code>known_methods</code> callback.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_type_of_resource_handler">Type of resource handler</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Am I writing a handler for a collection of resources,
+or for a single resource?</p></div>
+<div class="paragraph"><p>The semantics for each of these are quite different.
+You should not mix collection and single resource in
+the same handler.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_collection_handler">Collection handler</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Skip this section if you are not doing a collection.</p></div>
+<div class="paragraph"><p>Is the collection hardcoded or dynamic? For example,
+if you use the route <code>/users</code> for the collection of
+users then the collection is hardcoded; if you use
+<code>/forums/:category</code> for the collection of threads
+then it isn’t. When the collection is hardcoded you
+can safely assume the resource always exists.</p></div>
+<div class="paragraph"><p>What methods should I implement?</p></div>
+<div class="paragraph"><p>OPTIONS is used to get some information about the
+collection. It is recommended to allow it even if you
+do not implement it, as Cowboy has a default
+implementation built-in.</p></div>
+<div class="paragraph"><p>HEAD and GET are used to retrieve the collection.
+If you allow GET, also allow HEAD as there’s no extra
+work required to make it work.</p></div>
+<div class="paragraph"><p>POST is used to create a new resource inside the
+collection. Creating a resource by using POST on
+the collection is useful when resources may be
+created before knowing their URI, usually because
+parts of it are generated dynamically. A common
+case is some kind of auto incremented integer
+identifier.</p></div>
+<div class="paragraph"><p>The next methods are more rarely allowed.</p></div>
+<div class="paragraph"><p>PUT is used to create a new collection (when
+the collection isn’t hardcoded), or replace
+the entire collection.</p></div>
+<div class="paragraph"><p>DELETE is used to delete the entire collection.</p></div>
+<div class="paragraph"><p>PATCH is used to modify the collection using
+instructions given in the request body. A PATCH
+operation is atomic. The PATCH operation may
+be used for such things as reordering; adding,
+modifying or deleting parts of the collection.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_single_resource_handler">Single resource handler</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Skip this section if you are doing a collection.</p></div>
+<div class="paragraph"><p>What methods should I implement?</p></div>
+<div class="paragraph"><p>OPTIONS is used to get some information about the
+resource. It is recommended to allow it even if you
+do not implement it, as Cowboy has a default
+implementation built-in.</p></div>
+<div class="paragraph"><p>HEAD and GET are used to retrieve the resource.
+If you allow GET, also allow HEAD as there’s no extra
+work required to make it work.</p></div>
+<div class="paragraph"><p>POST is used to update the resource.</p></div>
+<div class="paragraph"><p>PUT is used to create a new resource (when it doesn’t
+already exist) or replace the resource.</p></div>
+<div class="paragraph"><p>DELETE is used to delete the resource.</p></div>
+<div class="paragraph"><p>PATCH is used to modify the resource using
+instructions given in the request body. A PATCH
+operation is atomic. The PATCH operation may
+be used for adding, removing or modifying specific
+values in the resource.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_the_resource">The resource</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Following the above discussion, implement the
+<code>allowed_methods</code> callback.</p></div>
+<div class="paragraph"><p>Does the resource always exist? If it may not, implement
+the <code>resource_exists</code> callback.</p></div>
+<div class="paragraph"><p>Do I need to authenticate the client before they can
+access the resource? What authentication mechanisms
+should I provide? This may include form-based, token-based
+(in the URL or a cookie), HTTP basic, HTTP digest,
+SSL certificate or any other form of authentication.
+Implement the <code>is_authorized</code> callback.</p></div>
+<div class="paragraph"><p>Do I need fine-grained access control? How do I determine
+that they are authorized access? Handle that in your
+<code>is_authorized</code> callback.</p></div>
+<div class="paragraph"><p>Can access to a resource be forbidden regardless of access
+being authorized? A simple example of that is censorship
+of a resource. Implement the <code>forbidden</code> callback.</p></div>
+<div class="paragraph"><p>Are there any constraints on the length of the resource URI?
+For example, the URI may be used as a key in storage and may
+have a limit in length. Implement <code>uri_too_long</code>.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_representations">Representations</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>What media types do I provide? If text based, what charsets
+are provided? What languages do I provide?</p></div>
+<div class="paragraph"><p>Implement the mandatory <code>content_types_provided</code>. Prefix
+the callbacks with <code>to_</code> for clarity. For example, <code>to_html</code>
+or <code>to_text</code>.</p></div>
+<div class="paragraph"><p>Implement the <code>languages_provided</code> or <code>charsets_provided</code>
+callbacks if applicable.</p></div>
+<div class="paragraph"><p>Is there any other header that may make the representation
+of the resource vary? Implement the <code>variances</code> callback.</p></div>
+<div class="paragraph"><p>Depending on your choices for caching content, you may
+want to implement one or more of the <code>generate_etag</code>,
+<code>last_modified</code> and <code>expires</code> callbacks.</p></div>
+<div class="paragraph"><p>Do I want the user or user agent to actively choose a
+representation available? Send a list of available
+representations in the response body and implement
+the <code>multiple_choices</code> callback.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_redirections">Redirections</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Do I need to keep track of what resources were deleted?
+For example, you may have a mechanism where moving a
+resource leaves a redirect link to its new location.
+Implement the <code>previously_existed</code> callback.</p></div>
+<div class="paragraph"><p>Was the resource moved, and is the move temporary? If
+it is explicitly temporary, for example due to maintenance,
+implement the <code>moved_temporarily</code> callback. Otherwise,
+implement the <code>moved_permanently</code> callback.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_the_request">The request</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Do we need to perform extra checks to make sure the request
+is valid? Cowboy will do many checks when receiving the
+request already, do we need more? Note that this only
+applies to the request-line and headers of the request,
+and not the body. Implement <code>malformed_request</code>.</p></div>
+<div class="paragraph"><p>May there be a request body? Will I know its size?
+What’s the maximum size of the request body I’m willing
+to accept? Implement <code>valid_entity_length</code>.</p></div>
+<div class="paragraph"><p>Finally, take a look at the sections corresponding to the
+methods you are implementing.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_options_method">OPTIONS method</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Cowboy by default will send back a list of allowed methods.
+Do I need to add more information to the response? Implement
+the <code>options</code> method.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_get_and_head_methods">GET and HEAD methods</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>If you implement the methods GET and/or HEAD, you must
+implement one <code>ProvideResource</code> callback for each
+content-type returned by the <code>content_types_provided</code>
+callback.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_put_post_and_patch_methods">PUT, POST and PATCH methods</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>If you implement the methods PUT, POST and/or PATCH,
+you must implement the <code>content_types_accepted</code> callback,
+and one <code>AcceptResource</code> callback for each content-type
+it returns. Prefix the <code>AcceptResource</code> callback names
+with <code>from_</code> for clarity. For example, <code>from_html</code> or
+<code>from_json</code>.</p></div>
+<div class="paragraph"><p>Do we want to allow the POST method to create individual
+resources directly through their URI (like PUT)? Implement
+the <code>allow_missing_post</code> callback. It is recommended to
+explicitly use PUT in these cases instead.</p></div>
+<div class="paragraph"><p>May there be conflicts when using PUT to create or replace
+a resource? Do we want to make sure that two updates around
+the same time are not cancelling one another? Implement the
+<code>is_conflict</code> callback.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_delete_methods">DELETE methods</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>If you implement the method DELETE, you must implement
+the <code>delete_resource</code> callback.</p></div>
+<div class="paragraph"><p>When <code>delete_resource</code> returns, is the resource completely
+removed from the server, including from any caching service?
+If not, and/or if the deletion is asynchronous and we have
+no way of knowing it has been completed yet, implement the
+<code>delete_completed</code> callback.</p></div>
+</div>
+</div>
+ + + +</div> + +<div class="span3 sidecol"> + + +<h3> + Cowboy + 2.0 + + User Guide +</h3> + +<ul> + + <li><a href="/docs/en/cowboy/2.0/guide">User Guide</a></li> + + + <li><a href="/docs/en/cowboy/2.0/manual">Function Reference</a></li> + + +</ul> + +<h4 id="docs-nav">Navigation</h4> + +<h4>Version select</h4> +<ul> + + + + <li><a href="/docs/en/cowboy/1.0/guide">1.0</a></li> + + <li><a href="/docs/en/cowboy/2.0/guide">2.0</a></li> + +</ul> + +</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 © Loïc Hoguin 2012-2016</p> + </div> + </div> + </div> + </footer> + + + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> + <script src="/js/bootstrap-carousel.js"></script> + <script src="/js/bootstrap-dropdown.js"></script> + <script src="/js/custom.js"></script> + </body> +</html> + + diff --git a/docs/en/cowboy/2.0/guide/resp.asciidoc b/docs/en/cowboy/2.0/guide/resp.asciidoc new file mode 100644 index 00000000..1ffdfbd5 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/resp.asciidoc @@ -0,0 +1,201 @@ +[[resp]] +== Sending a response + +The Req object also allows you to send a response. + +You can only send one response. Any other attempt will +trigger a crash. The response may be sent in one go or +with its body streamed by chunks of arbitrary size. + +You can also set headers or the response body in advance +and Cowboy will use them when you finally do reply. + +=== Reply + +You can send a reply with no particular headers or body. +Cowboy will make sure to send the mandatory headers with +the response. + +[source,erlang] +Req2 = cowboy_req:reply(200, Req). + +You can define headers to be sent with the response. Note +that header names must be lowercase. Again, Cowboy will +make sure to send the mandatory headers with the response. + +[source,erlang] +---- +Req2 = cowboy_req:reply(303, [ + {<<"location">>, <<"http://ninenines.eu">>} +], Req). +---- + +You can override headers that Cowboy would send otherwise. +Any header set by the user will be used over the ones set +by Cowboy. For example, you can advertise yourself as a +different server. + +[source,erlang] +---- +Req2 = cowboy_req:reply(200, [ + {<<"server">>, <<"yaws">>} +], Req). +---- + +We also saw earlier how to force close the connection by +overriding the connection header. + +Finally, you can also send a body with the response. Cowboy +will automatically set the content-length header if you do. +We recommend that you set the content-type header so the +client may know how to read the body. + +[source,erlang] +---- +Req2 = cowboy_req:reply(200, [ + {<<"content-type">>, <<"text/plain">>} +], "Hello world!", Req). +---- + +Here is the same example but sending HTML this time. + +[source,erlang] +---- +Req2 = cowboy_req:reply(200, [ + {<<"content-type">>, <<"text/html">>} +], "<html><head>Hello world!</head><body><p>Hats off!</p></body></html>", Req). +---- + +Note that the reply is sent immediately. + +=== Chunked reply + +You can also stream the response body. First, you need to +initiate the reply by sending the response status code. +Then you can send the body in chunks of arbitrary size. + +[source,erlang] +Req2 = cowboy_req:chunked_reply(200, Req), +cowboy_req:chunk("Hello...", Req2), +cowboy_req:chunk("chunked...", Req2), +cowboy_req:chunk("world!!", Req2). + +You should make sure to match on `ok` as an error may be +returned. + +While it is possible to send a chunked response without +a content-type header, it is still recommended. You can +set this header or any other just like for normal replies. + +[source,erlang] +---- +Req2 = cowboy_req:chunked_reply(200, [ + {<<"content-type">>, <<"text/html">>} +], Req), +cowboy_req:chunk("<html><head>Hello world!</head>", Req2), +cowboy_req:chunk("<body><p>Hats off!</p></body></html>", Req2). +---- + +Note that the reply and each chunk following it are sent +immediately. + +=== Preset response headers + +You can define response headers in advance. They will be +merged into the headers given in the reply call. Headers +in the reply call override preset response headers which +override the default Cowboy headers. + +[source,erlang] +Req2 = cowboy_req:set_resp_header(<<"allow">>, "GET", Req). + +You can check if a response header has already been set. +This will only check the response headers that you set, +and not the ones Cowboy will add when actually sending +the reply. + +[source,erlang] +cowboy_req:has_resp_header(<<"allow">>, Req). + +It will return `true` if the header is defined, and `false` +otherwise. + +Finally, you can also delete a preset response header if +needed. If you do, it will not be sent. + +[source,erlang] +Req2 = cowboy_req:delete_resp_header(<<"allow">>, Req). + +=== Preset response body + +You can set the response body in advance. Note that this +body will be ignored if you then choose to send a chunked +reply, or if you send a reply with an explicit body. + +[source,erlang] +Req2 = cowboy_req:set_resp_body("Hello world!", Req). + +You can also set a fun that will be called when it is time +to send the body. There are three different ways of doing +that. + +If you know the length of the body that needs to be sent, +you should specify it, as it will help clients determine +the remaining download time and allow them to inform the +user. + +[source,erlang] +---- +F = fun (Socket, Transport) -> + Transport:send(Socket, "Hello world!") +end, +Req2 = cowboy_req:set_resp_body_fun(12, F, Req). +---- + +If you do not know the length of the body, you should use +a chunked response body fun instead. + +[source,erlang] +---- +F = fun (SendChunk) -> + Body = lists:duplicate(random:uniform(1024, $a)), + SendChunk(Body) +end, +Req2 = cowboy_req:set_resp_body_fun(chunked, F, Req). +---- + +Finally, you can also send data on the socket directly, +without knowing the length in advance. Cowboy may be +forced to close the connection at the end of the response +though depending on the protocol capabilities. + +[source,erlang] +---- +F = fun (Socket, Transport) -> + Body = lists:duplicate(random:uniform(1024, $a)), + Transport:send(Socket, Body) +end, +Req2 = cowboy_req:set_resp_body_fun(F, Req). +---- + +=== Sending files + +You can send files directly from disk without having to +read them. Cowboy will use the `sendfile` syscall when +possible, which means that the file is sent to the socket +directly from the kernel, which is a lot more performant +than doing it from userland. + +Again, it is recommended to set the size of the file if it +can be known in advance. + +[source,erlang] +---- +F = fun (Socket, Transport) -> + Transport:sendfile(Socket, "priv/styles.css") +end, +Req2 = cowboy_req:set_resp_body_fun(FileSize, F, Req). +---- + +Please see the Ranch guide for more information about +sending files. diff --git a/docs/en/cowboy/2.0/guide/resp/index.html b/docs/en/cowboy/2.0/guide/resp/index.html new file mode 100644 index 00000000..0baaa4c9 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/resp/index.html @@ -0,0 +1,357 @@ +<!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"> + + <meta name="generator" content="Hugo 0.15" /> + + <title>Nine Nines: Sending a response</title> + + <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'> + + <link href="/css/bootstrap.min.css" rel="stylesheet"> + <link href="/css/99s.css" 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="Keep in touch!" href="http://twitter.com/lhoguin"><img src="/img/ico_microblog.png" data-hover="/img/ico_microblog_alt.png"></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>Sending a response</span></h1> + +<div class="paragraph"><p>The Req object also allows you to send a response.</p></div>
+<div class="paragraph"><p>You can only send one response. Any other attempt will
+trigger a crash. The response may be sent in one go or
+with its body streamed by chunks of arbitrary size.</p></div>
+<div class="paragraph"><p>You can also set headers or the response body in advance
+and Cowboy will use them when you finally do reply.</p></div>
+<div class="sect1">
+<h2 id="_reply">Reply</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>You can send a reply with no particular headers or body.
+Cowboy will make sure to send the mandatory headers with
+the response.</p></div>
+<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="color: #009900">Req2</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:reply</span></span>(<span style="color: #993399">200</span>, <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>You can define headers to be sent with the response. Note
+that header names must be lowercase. Again, Cowboy will
+make sure to send the mandatory headers with the response.</p></div>
+<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="color: #009900">Req2</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:reply</span></span>(<span style="color: #993399">303</span>, [
+ {<span style="color: #990000"><<</span><span style="color: #FF0000">"location"</span><span style="color: #990000">>></span>, <span style="color: #990000"><<</span><span style="color: #FF0000">"http://ninenines.eu"</span><span style="color: #990000">>></span>}
+], <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>You can override headers that Cowboy would send otherwise.
+Any header set by the user will be used over the ones set
+by Cowboy. For example, you can advertise yourself as a
+different server.</p></div>
+<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="color: #009900">Req2</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:reply</span></span>(<span style="color: #993399">200</span>, [
+ {<span style="color: #990000"><<</span><span style="color: #FF0000">"server"</span><span style="color: #990000">>></span>, <span style="color: #990000"><<</span><span style="color: #FF0000">"yaws"</span><span style="color: #990000">>></span>}
+], <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>We also saw earlier how to force close the connection by
+overriding the connection header.</p></div>
+<div class="paragraph"><p>Finally, you can also send a body with the response. Cowboy
+will automatically set the content-length header if you do.
+We recommend that you set the content-type header so the
+client may know how to read the body.</p></div>
+<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="color: #009900">Req2</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:reply</span></span>(<span style="color: #993399">200</span>, [
+ {<span style="color: #990000"><<</span><span style="color: #FF0000">"content-type"</span><span style="color: #990000">>></span>, <span style="color: #990000"><<</span><span style="color: #FF0000">"text/plain"</span><span style="color: #990000">>></span>}
+], <span style="color: #FF0000">"Hello world!"</span>, <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Here is the same example but sending HTML this time.</p></div>
+<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="color: #009900">Req2</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:reply</span></span>(<span style="color: #993399">200</span>, [
+ {<span style="color: #990000"><<</span><span style="color: #FF0000">"content-type"</span><span style="color: #990000">>></span>, <span style="color: #990000"><<</span><span style="color: #FF0000">"text/html"</span><span style="color: #990000">>></span>}
+], <span style="color: #FF0000">"<html><head>Hello world!</head><body><p>Hats off!</p></body></html>"</span>, <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Note that the reply is sent immediately.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_chunked_reply">Chunked reply</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>You can also stream the response body. First, you need to
+initiate the reply by sending the response status code.
+Then you can send the body in chunks of arbitrary size.</p></div>
+<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="color: #009900">Req2</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:chunked_reply</span></span>(<span style="color: #993399">200</span>, <span style="color: #009900">Req</span>),
+<span style="font-weight: bold"><span style="color: #000000">cowboy_req:chunk</span></span>(<span style="color: #FF0000">"Hello..."</span>, <span style="color: #009900">Req2</span>),
+<span style="font-weight: bold"><span style="color: #000000">cowboy_req:chunk</span></span>(<span style="color: #FF0000">"chunked..."</span>, <span style="color: #009900">Req2</span>),
+<span style="font-weight: bold"><span style="color: #000000">cowboy_req:chunk</span></span>(<span style="color: #FF0000">"world!!"</span>, <span style="color: #009900">Req2</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>You should make sure to match on <code>ok</code> as an error may be
+returned.</p></div>
+<div class="paragraph"><p>While it is possible to send a chunked response without
+a content-type header, it is still recommended. You can
+set this header or any other just like for normal replies.</p></div>
+<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="color: #009900">Req2</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:chunked_reply</span></span>(<span style="color: #993399">200</span>, [
+ {<span style="color: #990000"><<</span><span style="color: #FF0000">"content-type"</span><span style="color: #990000">>></span>, <span style="color: #990000"><<</span><span style="color: #FF0000">"text/html"</span><span style="color: #990000">>></span>}
+], <span style="color: #009900">Req</span>),
+<span style="font-weight: bold"><span style="color: #000000">cowboy_req:chunk</span></span>(<span style="color: #FF0000">"<html><head>Hello world!</head>"</span>, <span style="color: #009900">Req2</span>),
+<span style="font-weight: bold"><span style="color: #000000">cowboy_req:chunk</span></span>(<span style="color: #FF0000">"<body><p>Hats off!</p></body></html>"</span>, <span style="color: #009900">Req2</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Note that the reply and each chunk following it are sent
+immediately.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_preset_response_headers">Preset response headers</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>You can define response headers in advance. They will be
+merged into the headers given in the reply call. Headers
+in the reply call override preset response headers which
+override the default Cowboy headers.</p></div>
+<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="color: #009900">Req2</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:set_resp_header</span></span>(<span style="color: #990000"><<</span><span style="color: #FF0000">"allow"</span><span style="color: #990000">>></span>, <span style="color: #FF0000">"GET"</span>, <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>You can check if a response header has already been set.
+This will only check the response headers that you set,
+and not the ones Cowboy will add when actually sending
+the reply.</p></div>
+<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">cowboy_req:has_resp_header</span></span>(<span style="color: #990000"><<</span><span style="color: #FF0000">"allow"</span><span style="color: #990000">>></span>, <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>It will return <code>true</code> if the header is defined, and <code>false</code>
+otherwise.</p></div>
+<div class="paragraph"><p>Finally, you can also delete a preset response header if
+needed. If you do, it will not be sent.</p></div>
+<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="color: #009900">Req2</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:delete_resp_header</span></span>(<span style="color: #990000"><<</span><span style="color: #FF0000">"allow"</span><span style="color: #990000">>></span>, <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_preset_response_body">Preset response body</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>You can set the response body in advance. Note that this
+body will be ignored if you then choose to send a chunked
+reply, or if you send a reply with an explicit body.</p></div>
+<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="color: #009900">Req2</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:set_resp_body</span></span>(<span style="color: #FF0000">"Hello world!"</span>, <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>You can also set a fun that will be called when it is time
+to send the body. There are three different ways of doing
+that.</p></div>
+<div class="paragraph"><p>If you know the length of the body that needs to be sent,
+you should specify it, as it will help clients determine
+the remaining download time and allow them to inform the
+user.</p></div>
+<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="color: #009900">F</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">fun</span></span> (<span style="color: #009900">Socket</span>, <span style="color: #009900">Transport</span>) <span style="color: #990000">-></span>
+ <span style="color: #009900">Transport</span><span style="color: #990000">:</span><span style="font-weight: bold"><span style="color: #000000">send</span></span>(<span style="color: #009900">Socket</span>, <span style="color: #FF0000">"Hello world!"</span>)
+<span style="font-weight: bold"><span style="color: #0000FF">end</span></span>,
+<span style="color: #009900">Req2</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:set_resp_body_fun</span></span>(<span style="color: #993399">12</span>, <span style="color: #009900">F</span>, <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>If you do not know the length of the body, you should use
+a chunked response body fun instead.</p></div>
+<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="color: #009900">F</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">fun</span></span> (<span style="color: #009900">SendChunk</span>) <span style="color: #990000">-></span>
+ <span style="color: #009900">Body</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">lists:duplicate</span></span>(<span style="font-weight: bold"><span style="color: #000000">random:uniform</span></span>(<span style="color: #993399">1024</span>, <span style="color: #FF0000">$a</span>)),
+ <span style="color: #009900">SendChunk</span>(<span style="color: #009900">Body</span>)
+<span style="font-weight: bold"><span style="color: #0000FF">end</span></span>,
+<span style="color: #009900">Req2</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:set_resp_body_fun</span></span>(<span style="color: #FF6600">chunked</span>, <span style="color: #009900">F</span>, <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Finally, you can also send data on the socket directly,
+without knowing the length in advance. Cowboy may be
+forced to close the connection at the end of the response
+though depending on the protocol capabilities.</p></div>
+<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="color: #009900">F</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">fun</span></span> (<span style="color: #009900">Socket</span>, <span style="color: #009900">Transport</span>) <span style="color: #990000">-></span>
+ <span style="color: #009900">Body</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">lists:duplicate</span></span>(<span style="font-weight: bold"><span style="color: #000000">random:uniform</span></span>(<span style="color: #993399">1024</span>, <span style="color: #FF0000">$a</span>)),
+ <span style="color: #009900">Transport</span><span style="color: #990000">:</span><span style="font-weight: bold"><span style="color: #000000">send</span></span>(<span style="color: #009900">Socket</span>, <span style="color: #009900">Body</span>)
+<span style="font-weight: bold"><span style="color: #0000FF">end</span></span>,
+<span style="color: #009900">Req2</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:set_resp_body_fun</span></span>(<span style="color: #009900">F</span>, <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_sending_files">Sending files</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>You can send files directly from disk without having to
+read them. Cowboy will use the <code>sendfile</code> syscall when
+possible, which means that the file is sent to the socket
+directly from the kernel, which is a lot more performant
+than doing it from userland.</p></div>
+<div class="paragraph"><p>Again, it is recommended to set the size of the file if it
+can be known in advance.</p></div>
+<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="color: #009900">F</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #0000FF">fun</span></span> (<span style="color: #009900">Socket</span>, <span style="color: #009900">Transport</span>) <span style="color: #990000">-></span>
+ <span style="color: #009900">Transport</span><span style="color: #990000">:</span><span style="font-weight: bold"><span style="color: #000000">sendfile</span></span>(<span style="color: #009900">Socket</span>, <span style="color: #FF0000">"priv/styles.css"</span>)
+<span style="font-weight: bold"><span style="color: #0000FF">end</span></span>,
+<span style="color: #009900">Req2</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:set_resp_body_fun</span></span>(<span style="color: #009900">FileSize</span>, <span style="color: #009900">F</span>, <span style="color: #009900">Req</span>)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Please see the Ranch guide for more information about
+sending files.</p></div>
+</div>
+</div>
+ + + +</div> + +<div class="span3 sidecol"> + + +<h3> + Cowboy + 2.0 + + User Guide +</h3> + +<ul> + + <li><a href="/docs/en/cowboy/2.0/guide">User Guide</a></li> + + + <li><a href="/docs/en/cowboy/2.0/manual">Function Reference</a></li> + + +</ul> + +<h4 id="docs-nav">Navigation</h4> + +<h4>Version select</h4> +<ul> + + + + <li><a href="/docs/en/cowboy/1.0/guide">1.0</a></li> + + <li><a href="/docs/en/cowboy/2.0/guide">2.0</a></li> + +</ul> + +</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 © Loïc Hoguin 2012-2016</p> + </div> + </div> + </div> + </footer> + + + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> + <script src="/js/bootstrap-carousel.js"></script> + <script src="/js/bootstrap-dropdown.js"></script> + <script src="/js/custom.js"></script> + </body> +</html> + + diff --git a/docs/en/cowboy/2.0/guide/rest_cond.png b/docs/en/cowboy/2.0/guide/rest_cond.png Binary files differnew file mode 100644 index 00000000..64cda347 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/rest_cond.png diff --git a/docs/en/cowboy/2.0/guide/rest_cond.svg b/docs/en/cowboy/2.0/guide/rest_cond.svg new file mode 100644 index 00000000..542ae17d --- /dev/null +++ b/docs/en/cowboy/2.0/guide/rest_cond.svg @@ -0,0 +1,1656 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:osb="http://www.openswatchbook.org/uri/2009/osb" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="744.09448819" + height="1052.3622047" + id="svg2" + version="1.1" + inkscape:version="0.48.4 r9939" + sodipodi:docname="rest_cond.svg" + inkscape:export-filename="/home/essen/Dropbox/Public/drawing.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90"> + <defs + id="defs4"> + <linearGradient + id="linearGradient5265"> + <stop + style="stop-color:#69d2e7;stop-opacity:1;" + offset="0" + id="stop5267" /> + <stop + style="stop-color:#69d2e7;stop-opacity:0.58823532;" + offset="1" + id="stop5269" /> + </linearGradient> + <linearGradient + id="linearGradient5251"> + <stop + style="stop-color:#69d2e7;stop-opacity:0.78431374;" + offset="0" + id="stop5253" /> + <stop + id="stop5263" + offset="0.5" + style="stop-color:#69d2e7;stop-opacity:1;" /> + <stop + style="stop-color:#69d2e7;stop-opacity:0.39215687;" + offset="1" + id="stop5255" /> + </linearGradient> + <linearGradient + id="linearGradient5233" + osb:paint="solid"> + <stop + style="stop-color:#69d2e7;stop-opacity:1;" + offset="0" + id="stop5235" /> + </linearGradient> + </defs> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="1" + inkscape:pageshadow="2" + inkscape:zoom="2.0000001" + inkscape:cx="351.17815" + inkscape:cy="292.20555" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="false" + inkscape:window-width="2560" + inkscape:window-height="1402" + inkscape:window-x="0" + inkscape:window-y="38" + inkscape:window-maximized="1" + inkscape:snap-global="true" + showguides="true"> + <inkscape:grid + type="xygrid" + id="grid5357" + empspacing="5" + visible="true" + enabled="true" + snapvisiblegridlinesonly="true" /> + </sodipodi:namedview> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title /> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1"> + <path + inkscape:export-ydpi="89.926643" + inkscape:export-xdpi="89.926643" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:connector-curvature="0" + id="use5777" + d="m -360.31658,371.70113 203.00246,0.045" + style="fill:none;stroke:#6d8e41;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:1.99999999, 3.99999998;stroke-dashoffset:0" /> + <g + transform="translate(303.92143,-296.03137)" + id="g5650-7" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-9" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-0" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(303.92143,-212.00698)" + id="g5650-9" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-7" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-09" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(303.92143,-129.04326)" + id="g5650-0" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-5" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-1" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(303.92143,-44.866334)" + id="g5650-94" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-71" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-5" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(303.92143,38.329623)" + id="g5650-93" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-3" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-4" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(303.92143,122.59665)" + id="g5650-3" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-93" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-04" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(303.92143,206.62103)" + id="g5650-6" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-78" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-9" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="matrix(0,-1,1,0,-276.88574,248.85545)" + id="g5650-2-0" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <g + transform="matrix(0,-1,1,0,72.326854,331.8341)" + id="g5650-2-04" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-2-9" + d="m -57.78256,274.83062 0,129.13992" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-0" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-28" + width="210.17955" + height="35.209244" + x="141.04909" + y="204.49196" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-5" + width="210.17955" + height="35.209244" + x="141.04909" + y="288.06644" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-8" + width="210.17955" + height="35.209244" + x="141.04909" + y="371.6409" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-4" + width="210.17955" + height="35.209244" + x="141.04909" + y="455.21542" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <g + transform="matrix(0,-1,1,0,72.019862,498.61197)" + id="g5650-2-04-1" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-2-9-6" + d="m -57.78256,275.13761 0,129.13992" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-0-7" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-87" + width="210.17955" + height="35.209244" + x="141.04909" + y="538.78992" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <g + transform="translate(303.92156,289.38374)" + id="g5650-6-2" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-78-4" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-9-2" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="matrix(0,-1,1,0,-273.77202,830.73267)" + id="g5650-2-0-4-0" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172-9-9" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-3" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <g + transform="matrix(0,-1,1,0,-276.00956,743.77999)" + id="g5650-2-0-4-9-4" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 100.30195,432.97597 c 0,0 -104.1879007,-96.82159 -227.75958,-12.49311" + id="path20172-9-6-0" + inkscape:connector-curvature="0" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,146.48523,357.79168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-5-7" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-41" + width="210.17955" + height="35.209244" + x="140.98338" + y="622.36444" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1" + width="210.17955" + height="35.209244" + x="141.04909" + y="120.91741" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <g + id="g5650" + transform="translate(0,-0.47597102)"> + <path + inkscape:connector-curvature="0" + id="path5570" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273" + width="104.5895" + height="36.392323" + x="-224.02068" + y="29.41218" + rx="15" /> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7" + width="104.5895" + height="36.392323" + x="-224.02068" + y="90.691978" + rx="15" /> + <rect + style="fill:#ffc48c;fill-opacity:1;fill-rule:nonzero;stroke:#d79c64;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-2" + width="104.5895" + height="36.392323" + x="-224.02068" + y="151.97169" + rx="15" /> + <rect + style="fill:#ff9f80;fill-opacity:1;fill-rule:nonzero;stroke:#d77758;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-22" + width="104.5895" + height="36.392323" + x="-224.02068" + y="213.25146" + rx="15" /> + <rect + style="fill:#f56991;fill-opacity:1;fill-rule:nonzero;stroke:#cd4169;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-8" + width="104.5895" + height="36.392323" + x="-224.02068" + y="274.53128" + rx="15" /> + <use + x="0" + y="0" + xlink:href="#rect5273-22" + id="use5355" + transform="translate(417.86479,-176.50006)" + width="744.09448" + height="1052.3622" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="-58.692513" + y="114.39204" + id="text5371" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373" + x="-58.692513" + y="114.39204">some text</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="-58.692513" + y="53.112247" + id="text5371-2" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-6" + x="-58.692513" + y="53.112247">some text</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="246.18575" + y="311.63589" + id="text5371-2-3" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-7" + x="246.18575" + y="311.63589">has if-unmodified-since?</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="245.60762" + y="478.78488" + id="text5371-2-3-0" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-7-3" + x="245.60762" + y="478.78488">has if-none-match?</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="-58.692513" + y="236.95154" + id="text5371-4" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-9" + x="-58.692513" + y="236.95154">some text</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="246.15059" + y="55.939754" + id="text5371-4-0" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + x="246.15059" + y="55.939754" + id="tspan17171">...</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="246.11153" + y="560.125" + id="text5371-2-9" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-8" + x="246.11153" + y="560.125">generate_etag</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="246.64278" + y="645.9339" + id="text5371-2-7" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-2" + x="246.64278" + y="645.9339">has if-modified-since?</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="246.13106" + y="144.48688" + id="text5371-2-95" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-80" + x="246.13106" + y="144.48688">has if-match?</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="245.80684" + y="225.82706" + id="text5371-2-32" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-27" + x="245.80684" + y="225.82706">generate_etag</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="246.05293" + y="393.43692" + id="text5371-2-74" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-18" + x="246.05293" + y="393.43692">last_modified</tspan></text> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-2" + width="210.17955" + height="35.209244" + x="-489.75586" + y="33.4944" + rx="15" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="262.26562" + y="185.95248" + id="text5371-2-391" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-63" + x="262.26562" + y="185.95248">true</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="262.26562" + y="269.61978" + id="text5371-2-954" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-808" + x="262.26562" + y="269.61978">match*</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="262.26562" + y="353.28702" + id="text5371-2-4" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-11" + x="262.26562" + y="353.28702">true</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="262.26562" + y="436.95425" + id="text5371-2-92" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-4" + x="262.26562" + y="436.95425">not modified*</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="262.26562" + y="520.62152" + id="text5371-2-739" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-0" + x="262.26562" + y="520.62152">true</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="261.24219" + y="604.14661" + id="text5371-2-8" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-3" + x="261.24219" + y="604.14661">no match*</tspan></text> + <g + transform="matrix(0,-1,1,0,-513.31414,353.05561)" + id="g5650-2"> + <path + inkscape:connector-curvature="0" + id="path5570-2" + d="m -57.78256,275.13761 0,129.13992" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="66.515488" + y="227.88033" + id="text5371-4-6" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-0" + x="66.515488" + y="227.88033">false</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="66.097519" + y="385.50708" + id="text5371-4-2" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-01" + x="66.097519" + y="385.50708">false, or</tspan><tspan + sodipodi:role="line" + x="66.097519" + y="405.50708" + id="tspan21678">invalid</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="413.26172" + y="414.19577" + id="text5371-4-3" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-62" + x="413.26172" + y="414.19577">modified*</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="66.515488" + y="563.13391" + id="text5371-4-4" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-2" + x="66.515488" + y="563.13391">false</tspan></text> + <g + transform="matrix(-1,0,0,-1,541.38289,824.55574)" + id="g5650-2-2"> + <path + inkscape:connector-curvature="0" + id="path5570-2-1" + d="m -57.78256,275.13761 0,129.13992" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-5" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:2.73499846;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-1" + width="218.52127" + height="34.993004" + x="489.90482" + y="372.18814" + rx="12.372616" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="599.20062" + y="394.09869" + id="text5371-43" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-3" + x="599.20062" + y="394.09869">412 precondition failed</tspan></text> + <rect + style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:2.44279909;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5367" + width="207.05719" + height="171.55719" + x="-373.52859" + y="458.58362" + rx="11.072577" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="-544.69421" + y="-354.17184" + id="text5371-2-3-0-7" + sodipodi:linespacing="125%" + transform="matrix(0,-1,1,0,0,0)" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-7-3-9" + x="-544.69421" + y="-354.17184">middlewares</tspan></text> + <g + transform="matrix(0,-1,1,0,-508.93096,565.23553)" + id="g5650-2-0-4" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172-9" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <g + transform="matrix(0,-1,1,0,-276.88574,416.17722)" + id="g5650-2-0-4-9" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172-9-6" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-5" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <g + transform="matrix(0,-1,1,0,-276.88574,583.49898)" + id="g5650-2-0-4-5" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172-9-0" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-6" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <g + transform="matrix(0.70472302,-0.70948254,0.70948254,0.70472302,241.97558,40.02582)" + id="g5650-2-1-3" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-2-2-8" + d="m -64.113139,212.68162 6.332851,190.92097" + style="opacity:0.80000000000000004;fill:none;stroke:#9b3b1c;stroke-width:1.99999999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-9-3" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="511.01306" + y="-49.514503" + id="text5371-4-5-9" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" + transform="matrix(0.72036037,0.69359998,-0.69359998,0.72036037,0,0)"><tspan + sodipodi:role="line" + id="tspan5373-9-09-1" + x="511.01306" + y="-49.514503">no match*</tspan></text> + <g + transform="translate(303.92156,371.88426)" + id="g5650-6-2-8" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-78-4-2" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-9-2-0" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-41-0" + width="210.17955" + height="35.209244" + x="140.98338" + y="705.93896" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="246.11142" + y="729.50842" + id="text5371-2-7-9" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-2-1" + x="246.11142" + y="729.50842">date is in the future?</tspan></text> + <g + transform="translate(303.92156,455.39272)" + id="g5650-6-2-1" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-78-4-6" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-9-2-2" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="matrix(0,-1,1,0,72.385532,749.33549)" + id="g5650-2-04-1-2" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-2-9-6-9" + d="m -57.78256,275.13761 0,129.13992" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-0-7-5" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-2-6" + width="210.17955" + height="35.209244" + x="140.98338" + y="789.51343" + rx="15" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="246.04581" + y="811.30945" + id="text5371-2-7-9-0" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-2-1-1" + x="246.04581" + y="811.30945">last_modified</tspan></text> + <g + id="g5650-39" + transform="translate(656.94774,376.09516)"> + <path + inkscape:connector-curvature="0" + id="path5570-0" + d="m -57.78256,195.3221 0,204.64594" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,159.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-124" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:2.73499846;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-1-7" + width="218.52127" + height="34.993004" + x="489.90482" + y="957.01166" + rx="12.372616" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="599.28265" + y="980.47302" + id="text5371-43-0" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-3-6" + x="599.28265" + y="980.47302">304 not modified</tspan></text> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-2-6-4" + width="210.17955" + height="35.209244" + x="140.98338" + y="873.08795" + rx="15" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="246.08487" + y="891.68475" + id="text5371-2-7-9-0-3" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-2-1-1-0" + x="246.08487" + y="891.68475">...</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="66.097519" + y="720.76068" + id="text5371-4-2-5" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-01-9" + x="66.097519" + y="720.76068">false, or</tspan><tspan + sodipodi:role="line" + x="66.097519" + y="740.76068" + id="tspan21678-9">invalid</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="412.95471" + y="580.78271" + id="text5371-4-3-9" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-62-9" + x="412.95471" + y="580.78271">match*</tspan></text> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3.05435514;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-41-0-7" + width="218.20164" + height="35.154888" + x="490.06448" + y="538.81708" + rx="15.572517" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="599.00122" + y="562.35938" + id="text5371-2-7-9-04" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-2-1-6" + x="599.00122" + y="562.35938">method is GET/HEAD?</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="621.08008" + y="607.0827" + id="text5371-2-739-3" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-0-0" + x="621.08008" + y="607.0827">true</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="640.17383" + y="518.34009" + id="text5371-4-4-9" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-2-6" + x="640.17383" + y="518.34009">false</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="157.927" + y="770.83472" + id="text5371-4-4-4" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-2-4" + x="157.927" + y="770.83472">true</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="262.32812" + y="771.29565" + id="text5371-2-739-5" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-0-1" + x="262.32812" + y="771.29565">false</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="262.26562" + y="687.26025" + id="text5371-2-739-56" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-0-8" + x="262.26562" + y="687.26025">true</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="261.24219" + y="854.87012" + id="text5371-2-739-5-6" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-0-1-3" + x="261.24219" + y="854.87012">modified*</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="417.07037" + y="834.64905" + id="text5371-4-3-9-9" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-62-9-4" + x="417.07037" + y="834.64905">not modified*</tspan></text> + <g + transform="translate(656.94774,455.40497)" + id="g5650-6-2-3" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-78-4-1" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-9-2-09" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-28-5" + width="210.17955" + height="35.209244" + x="490.03729" + y="789.51343" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="595.41223" + y="810.84851" + id="text5371-2-32-1" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-27-8" + x="595.41223" + y="810.84851">generate_etag</tspan></text> + <g + transform="translate(656.94774,539.41312)" + id="g5650-6-2-6" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-78-4-7" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-9-2-5" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-28-5-0" + width="210.17955" + height="35.209244" + x="490.03729" + y="873.08795" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="595.41223" + y="894.42303" + id="text5371-2-32-1-2" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-27-8-6" + x="595.41223" + y="894.42303">expires</tspan></text> + </g> +</svg> diff --git a/docs/en/cowboy/2.0/guide/rest_conneg.png b/docs/en/cowboy/2.0/guide/rest_conneg.png Binary files differnew file mode 100644 index 00000000..65ecdcf3 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/rest_conneg.png diff --git a/docs/en/cowboy/2.0/guide/rest_conneg.svg b/docs/en/cowboy/2.0/guide/rest_conneg.svg new file mode 100644 index 00000000..247567a0 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/rest_conneg.svg @@ -0,0 +1,1135 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:osb="http://www.openswatchbook.org/uri/2009/osb" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="744.09448819" + height="1052.3622047" + id="svg2" + version="1.1" + inkscape:version="0.48.4 r9939" + sodipodi:docname="rest_conneg.svg" + inkscape:export-filename="/home/essen/Dropbox/Public/drawing.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90"> + <defs + id="defs4"> + <linearGradient + id="linearGradient5265"> + <stop + style="stop-color:#69d2e7;stop-opacity:1;" + offset="0" + id="stop5267" /> + <stop + style="stop-color:#69d2e7;stop-opacity:0.58823532;" + offset="1" + id="stop5269" /> + </linearGradient> + <linearGradient + id="linearGradient5251"> + <stop + style="stop-color:#69d2e7;stop-opacity:0.78431374;" + offset="0" + id="stop5253" /> + <stop + id="stop5263" + offset="0.5" + style="stop-color:#69d2e7;stop-opacity:1;" /> + <stop + style="stop-color:#69d2e7;stop-opacity:0.39215687;" + offset="1" + id="stop5255" /> + </linearGradient> + <linearGradient + id="linearGradient5233" + osb:paint="solid"> + <stop + style="stop-color:#69d2e7;stop-opacity:1;" + offset="0" + id="stop5235" /> + </linearGradient> + </defs> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="1" + inkscape:pageshadow="2" + inkscape:zoom="1.4142136" + inkscape:cx="222.80947" + inkscape:cy="634.56615" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="false" + inkscape:window-width="2560" + inkscape:window-height="1402" + inkscape:window-x="0" + inkscape:window-y="38" + inkscape:window-maximized="1" + inkscape:snap-global="true" + showguides="true"> + <inkscape:grid + type="xygrid" + id="grid5357" + empspacing="5" + visible="true" + enabled="true" + snapvisiblegridlinesonly="true" /> + </sodipodi:namedview> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1"> + <path + inkscape:export-ydpi="89.926643" + inkscape:export-xdpi="89.926643" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:connector-curvature="0" + id="use5777" + d="m -360.31658,371.70113 203.00246,0.045" + style="fill:none;stroke:#6d8e41;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:1.99999999, 3.99999998;stroke-dashoffset:0" /> + <g + transform="translate(303.92143,-296.03137)" + id="g5650-7" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-9" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-0" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(303.92143,-212.00698)" + id="g5650-9" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-7" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-09" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(303.92143,-129.04326)" + id="g5650-0" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-5" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-1" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(303.92143,-44.866334)" + id="g5650-94" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-71" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-5" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(303.92143,38.329623)" + id="g5650-93" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-3" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-4" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(303.92143,122.59665)" + id="g5650-3" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-93" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-04" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(303.92143,206.62103)" + id="g5650-6" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-78" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-9" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="matrix(0,-1,1,0,-276.88574,248.85545)" + id="g5650-2-0" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <g + transform="matrix(0,-1,1,0,72.326854,331.8341)" + id="g5650-2-04" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-2-9" + d="m -57.78256,275.13761 0,129.13992" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-0" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-28" + width="210.17955" + height="35.209244" + x="141.04909" + y="204.67757" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-5" + width="210.17955" + height="35.209244" + x="141.04909" + y="288.40311" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-8" + width="210.17955" + height="35.209244" + x="141.04909" + y="372.01199" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-4" + width="210.17955" + height="35.209244" + x="141.04909" + y="455.67929" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-87" + width="210.17955" + height="35.209244" + x="141.04909" + y="539.34656" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <g + transform="translate(303.92156,289.38374)" + id="g5650-6-2" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-78-4" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-9-2" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-41" + width="210.17955" + height="35.209244" + x="141.04909" + y="623.01385" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1" + width="210.17955" + height="35.209244" + x="141.04909" + y="121.0042" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <g + id="g5650" + transform="translate(0,-0.47597102)"> + <path + inkscape:connector-curvature="0" + id="path5570" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273" + width="104.5895" + height="36.392323" + x="-224.02068" + y="29.41218" + rx="15" /> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7" + width="104.5895" + height="36.392323" + x="-224.02068" + y="90.691978" + rx="15" /> + <rect + style="fill:#ffc48c;fill-opacity:1;fill-rule:nonzero;stroke:#d79c64;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-2" + width="104.5895" + height="36.392323" + x="-224.02068" + y="151.97169" + rx="15" /> + <rect + style="fill:#ff9f80;fill-opacity:1;fill-rule:nonzero;stroke:#d77758;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-22" + width="104.5895" + height="36.392323" + x="-224.02068" + y="213.25146" + rx="15" /> + <rect + style="fill:#f56991;fill-opacity:1;fill-rule:nonzero;stroke:#cd4169;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-8" + width="104.5895" + height="36.392323" + x="-224.02068" + y="274.53128" + rx="15" /> + <use + x="0" + y="0" + xlink:href="#rect5273-22" + id="use5355" + transform="translate(417.86479,-176.50006)" + width="744.09448" + height="1052.3622" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="-58.692513" + y="114.39204" + id="text5371" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373" + x="-58.692513" + y="114.39204">some text</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="-58.692513" + y="53.112247" + id="text5371-2" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-6" + x="-58.692513" + y="53.112247">some text</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="246.18575" + y="310.19913" + id="text5371-2-3" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-7" + x="246.18575" + y="310.19913">has accept-language?</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="245.60762" + y="477.47531" + id="text5371-2-3-0" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-7-3" + x="245.60762" + y="477.47531">has accept-charset?</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="-58.692513" + y="236.95154" + id="text5371-4" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-9" + x="-58.692513" + y="236.95154">some text</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="245.00391" + y="60.912468" + id="text5371-4-0" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + x="245.00391" + y="60.912468" + id="tspan17171">start</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="246.11153" + y="561.14258" + id="text5371-2-9" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-8" + x="246.11153" + y="561.14258">charsets_provided</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="246.64278" + y="646.58331" + id="text5371-2-7" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-2" + x="246.64278" + y="646.58331">variances</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="246.13106" + y="142.80627" + id="text5371-2-95" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-80" + x="246.13106" + y="142.80627">has accept?</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="245.80684" + y="226.4736" + id="text5371-2-32" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-27" + x="245.80684" + y="226.4736">content_types_provided</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="246.05293" + y="393.80801" + id="text5371-2-74" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-18" + x="246.05293" + y="393.80801">languages_provided</tspan></text> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-2" + width="210.17955" + height="35.209244" + x="-489.75586" + y="33.4944" + rx="15" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="262.26562" + y="185.95248" + id="text5371-2-391" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-63" + x="262.26562" + y="185.95248">true</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="262.26562" + y="269.61978" + id="text5371-2-954" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-808" + x="262.26562" + y="269.61978">provided*</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="262.26562" + y="353.28702" + id="text5371-2-4" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-11" + x="262.26562" + y="353.28702">true</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="262.26562" + y="436.95425" + id="text5371-2-92" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-4" + x="262.26562" + y="436.95425">provided*</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="262.26562" + y="520.62152" + id="text5371-2-739" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-0" + x="262.26562" + y="520.62152">true</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="262.26562" + y="604.28876" + id="text5371-2-8" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-3" + x="262.26562" + y="604.28876">provided*</tspan></text> + <g + transform="matrix(0,-1,1,0,-513.31414,353.05561)" + id="g5650-2"> + <path + inkscape:connector-curvature="0" + id="path5570-2" + d="m -57.78256,275.13761 0,129.13992" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="76.761719" + y="227.88033" + id="text5371-4-6" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-0" + x="76.761719" + y="227.88033">false</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="76.761719" + y="395.20209" + id="text5371-4-2" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-01" + x="76.761719" + y="395.20209">false</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="413.26172" + y="374.19577" + id="text5371-4-3" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-62" + x="413.26172" + y="374.19577">not provided*</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="76.761719" + y="562.52386" + id="text5371-4-4" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-2" + x="76.761719" + y="562.52386">false</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="-8.8034744" + y="663.24762" + id="text5371-4-5" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" + transform="matrix(0.7410941,-0.67140117,0.67140117,0.7410941,0,0)"><tspan + sodipodi:role="line" + id="tspan5373-9-09" + x="-8.8034744" + y="663.24762">not provided*</tspan></text> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:2.73499846;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-1" + width="218.52127" + height="34.993004" + x="489.90482" + y="372.18814" + rx="12.372616" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <g + transform="matrix(-0.65781496,-0.75317958,0.75317958,-0.65781496,150.24236,637.46542)" + id="g5650-2-1" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-2-2" + d="m -59.488319,210.57681 1.65844,193.00059" + style="opacity:0.80000000000000004;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-9" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="599.20062" + y="394.09869" + id="text5371-43" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-3" + x="599.20062" + y="394.09869">406 not acceptable</tspan></text> + <rect + style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:2.44279909;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5367" + width="207.05719" + height="171.55719" + x="-373.52859" + y="458.58362" + rx="11.072577" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="-544.69421" + y="-354.17184" + id="text5371-2-3-0-7" + sodipodi:linespacing="125%" + transform="matrix(0,-1,1,0,0,0)" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-7-3-9" + x="-544.69421" + y="-354.17184">middlewares</tspan></text> + <g + transform="matrix(0,-1,1,0,-508.93096,565.23553)" + id="g5650-2-0-4" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172-9" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <g + transform="matrix(0,-1,1,0,-276.88574,416.17722)" + id="g5650-2-0-4-9" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172-9-6" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-5" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <g + transform="matrix(0,-1,1,0,-276.88574,583.49898)" + id="g5650-2-0-4-5" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172-9-0" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-6" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <g + transform="matrix(0.70472302,-0.70948254,0.70948254,0.70472302,241.97558,40.02582)" + id="g5650-2-1-3" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-2-2-8" + d="m -64.113139,212.68162 6.332851,190.92097" + style="opacity:0.80000000000000004;fill:none;stroke:#9b3b1c;stroke-width:1.99999999;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-9-3" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="509.41452" + y="-106.16136" + id="text5371-4-5-9" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" + transform="matrix(0.69480867,0.71919462,-0.71919462,0.69480867,0,0)"><tspan + sodipodi:role="line" + id="tspan5373-9-09-1" + x="509.41452" + y="-106.16136">not provided*</tspan></text> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-41-0" + width="210.17955" + height="35.209244" + x="141.049" + y="706.68097" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="246.15048" + y="725.27777" + id="text5371-2-7-9" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-2-1" + x="246.15048" + y="725.27777">...</tspan></text> + </g> +</svg> diff --git a/docs/en/cowboy/2.0/guide/rest_delete.png b/docs/en/cowboy/2.0/guide/rest_delete.png Binary files differnew file mode 100644 index 00000000..56a861c0 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/rest_delete.png diff --git a/docs/en/cowboy/2.0/guide/rest_delete.svg b/docs/en/cowboy/2.0/guide/rest_delete.svg new file mode 100644 index 00000000..2f5513cd --- /dev/null +++ b/docs/en/cowboy/2.0/guide/rest_delete.svg @@ -0,0 +1,1718 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:osb="http://www.openswatchbook.org/uri/2009/osb" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="744.09448819" + height="1052.3622047" + id="svg2" + version="1.1" + inkscape:version="0.48.4 r9939" + sodipodi:docname="rest_delete.svg" + inkscape:export-filename="/home/essen/Dropbox/Public/drawing.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90"> + <defs + id="defs4"> + <linearGradient + id="linearGradient5265"> + <stop + style="stop-color:#69d2e7;stop-opacity:1;" + offset="0" + id="stop5267" /> + <stop + style="stop-color:#69d2e7;stop-opacity:0.58823532;" + offset="1" + id="stop5269" /> + </linearGradient> + <linearGradient + id="linearGradient5251"> + <stop + style="stop-color:#69d2e7;stop-opacity:0.78431374;" + offset="0" + id="stop5253" /> + <stop + id="stop5263" + offset="0.5" + style="stop-color:#69d2e7;stop-opacity:1;" /> + <stop + style="stop-color:#69d2e7;stop-opacity:0.39215687;" + offset="1" + id="stop5255" /> + </linearGradient> + <linearGradient + id="linearGradient5233" + osb:paint="solid"> + <stop + style="stop-color:#69d2e7;stop-opacity:1;" + offset="0" + id="stop5235" /> + </linearGradient> + </defs> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="1" + inkscape:pageshadow="2" + inkscape:zoom="1.4142136" + inkscape:cx="187.51922" + inkscape:cy="446.38557" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="false" + inkscape:window-width="2560" + inkscape:window-height="1402" + inkscape:window-x="0" + inkscape:window-y="38" + inkscape:window-maximized="1" + inkscape:snap-global="true" + showguides="true"> + <inkscape:grid + type="xygrid" + id="grid5357" + empspacing="5" + visible="true" + enabled="true" + snapvisiblegridlinesonly="true" /> + </sodipodi:namedview> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1"> + <path + inkscape:export-ydpi="89.926643" + inkscape:export-xdpi="89.926643" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:connector-curvature="0" + id="use5777" + d="m -360.31658,371.70113 203.00246,0.045" + style="fill:none;stroke:#6d8e41;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:1.99999999, 3.99999998;stroke-dashoffset:0" /> + <g + transform="translate(416.63925,-305.0045)" + id="g5650-7" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-9" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-0" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(270.88515,270.15614)" + id="g5650-3" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-93" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-04" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(270.88515,435.68973)" + id="g5650-6" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-78" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-9" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(270.88515,-141.93971)" + id="g5650-0-8" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-5-3" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-1-1" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(270.88515,-59.713866)" + id="g5650-0-6-5" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-5-7-7" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-1-3-8" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="matrix(0,-1,1,0,-307.35528,398.54403)" + id="g5650-2-0-4-8-8-9" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172-9-5-6-2" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-2-8-3" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-28" + width="210.17955" + height="35.209244" + x="108.01281" + y="275.4668" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <g + transform="translate(270.88515,105.33602)" + id="g5650-2-2-7"> + <path + inkscape:connector-curvature="0" + id="path5570-2-1-3" + d="m -57.78256,343.20394 0,61.59661" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-5-9" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="matrix(0,-1,1,0,-310.05718,566.15049)" + id="g5650-2-0-4-3-8-3" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172-9-8-9-8" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-58-6-7" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-5" + width="210.17955" + height="35.209244" + x="108.01281" + y="440.50873" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <g + transform="matrix(0,-1,1,0,-308.28941,729.66893)" + id="g5650-2-0-4-8-8" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172-9-5-6" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-2-8" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-4" + width="210.17955" + height="35.209244" + x="108.01281" + y="605.5506" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <g + transform="matrix(0,-1,1,0,-313.39862,891.55835)" + id="g5650-2-0-4-8" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172-9-5" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-2" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-87" + width="210.17955" + height="35.209244" + x="108.01281" + y="770.83313" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <g + transform="matrix(0.70710678,-0.70710678,0.70710678,0.70710678,261.76354,-143.71473)" + id="g5650-2-2-8"> + <path + inkscape:connector-curvature="0" + id="path5570-2-1-4" + d="m -57.78256,343.20394 0,61.59661" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-5-3" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1" + width="210.17955" + height="35.209244" + x="253.76691" + y="112.69559" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <g + id="g5650" + transform="translate(0,-0.47597102)"> + <path + inkscape:connector-curvature="0" + id="path5570" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273" + width="104.5895" + height="36.392323" + x="-224.02068" + y="29.41218" + rx="15" /> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7" + width="104.5895" + height="36.392323" + x="-224.02068" + y="90.691978" + rx="15" /> + <rect + style="fill:#ffc48c;fill-opacity:1;fill-rule:nonzero;stroke:#d79c64;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-2" + width="104.5895" + height="36.392323" + x="-224.02068" + y="151.97169" + rx="15" /> + <rect + style="fill:#ff9f80;fill-opacity:1;fill-rule:nonzero;stroke:#d77758;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-22" + width="104.5895" + height="36.392323" + x="-224.02068" + y="213.25146" + rx="15" /> + <rect + style="fill:#f56991;fill-opacity:1;fill-rule:nonzero;stroke:#cd4169;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-8" + width="104.5895" + height="36.392323" + x="-224.02068" + y="274.53128" + rx="15" /> + <use + x="0" + y="0" + xlink:href="#rect5273-22" + id="use5355" + transform="translate(530.58261,-183.7816)" + width="744.09448" + height="1052.3622" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="-58.692513" + y="114.39204" + id="text5371" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373" + x="-58.692513" + y="114.39204">some text</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="-58.692513" + y="53.112247" + id="text5371-2" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-6" + x="-58.692513" + y="53.112247">some text</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="213.38774" + y="462.30475" + id="text5371-2-3" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-7" + x="213.38774" + y="462.30475">delete_completed</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="212.93852" + y="627.56927" + id="text5371-2-3-0" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-7-3" + x="212.93852" + y="627.56927">has response body?</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="-58.692513" + y="236.95154" + id="text5371-4" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-9" + x="-58.692513" + y="236.95154">some text</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="359.14185" + y="50.482433" + id="text5371-4-0" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + x="359.14185" + y="50.482433" + id="tspan17171">conneg</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="212.77055" + y="792.62915" + id="text5371-2-9" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-8" + x="212.77055" + y="792.62915">multiple_choices</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="358.52466" + y="134.49161" + id="text5371-2-95" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-80" + x="358.52466" + y="134.49161">resource_exists</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="213.08696" + y="297.26282" + id="text5371-2-32" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-27" + x="213.08696" + y="297.26282">delete_resource</tspan></text> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-2" + width="210.17955" + height="35.209244" + x="-489.75586" + y="33.4944" + rx="15" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="251.83722" + y="175.92931" + id="text5371-2-391" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-63" + x="251.83722" + y="175.92931">true</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="159.54012" + y="835.54285" + id="text5371-2-8" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-3" + x="159.54012" + y="835.54285">false</tspan></text> + <g + transform="matrix(0,-1,1,0,-513.31414,353.05561)" + id="g5650-2"> + <path + inkscape:connector-curvature="0" + id="path5570-2" + d="m -57.78256,275.13761 0,129.13992" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="447.26678" + y="176.39024" + id="text5371-4-6" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-0" + x="447.26678" + y="176.39024">false</tspan></text> + <g + transform="translate(563.72619,-141.76777)" + id="g5650-2-2"> + <path + inkscape:connector-curvature="0" + id="path5570-2-1" + d="m -57.78256,343.20394 0,61.59661" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-5" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:2.44279909;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5367" + width="207.05719" + height="171.55719" + x="-373.52859" + y="458.58362" + rx="11.072577" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="-544.69421" + y="-354.17184" + id="text5371-2-3-0-7" + sodipodi:linespacing="125%" + transform="matrix(0,-1,1,0,0,0)" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-7-3-9" + x="-544.69421" + y="-354.17184">middlewares</tspan></text> + <g + transform="matrix(0,-1,1,0,-508.93096,565.23553)" + id="g5650-2-0-4" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172-9" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="47.338913" + y="876.22211" + id="text5371-4-3-9" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-62-9" + x="47.338913" + y="876.22211">true</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="545.12921" + y="257.43518" + id="text5371-4-4-9" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-2-6" + x="545.12921" + y="257.43518">true</tspan></text> + <g + transform="matrix(0.70710678,0.70710678,-0.70710678,0.70710678,547.47379,-62.310424)" + id="g5650-9-9" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-7-6" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-09-5" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <use + x="0" + y="0" + xlink:href="#rect5273-22" + id="use5355-0" + transform="translate(384.82851,-20.897068)" + width="744.09448" + height="1052.3622" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="213.38774" + y="216.5154" + id="text5371-4-0-8" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + x="213.38774" + y="216.5154" + id="tspan17171-6">cond</tspan></text> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:2.73499846;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-1-1" + width="218.52127" + height="34.993004" + x="99.803589" + y="935.6217" + rx="12.372616" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="208.84938" + y="957.53229" + id="text5371-43-5" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-3-62" + x="208.84938" + y="957.53229">300 multiple choices</tspan></text> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:2.73499846;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-1-8" + width="218.52127" + height="34.993004" + x="99.803589" + y="853.22168" + rx="12.372616" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="208.31422" + y="876.54242" + id="text5371-43-3" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-3-1" + x="208.31422" + y="876.54242">200 OK</tspan></text> + <g + transform="matrix(0,-1,-1,0,1028.2004,317.70407)" + id="g5650-2-0-4-3-8" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172-9-8-9" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-58-6" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-28-4" + width="210.17955" + height="35.209244" + x="400.85385" + y="192.94594" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="505.77957" + y="216.51541" + id="text5371-2-32-6" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-27-8" + x="505.77957" + y="216.51541">has if-match?</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="651.74426" + y="299.27689" + id="text5371-2-391-5" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-63-7" + x="651.74426" + y="299.27689">false</tspan></text> + <g + transform="translate(563.72619,22.800669)" + id="g5650-0-6" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-5-7" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-1-3" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="matrix(0,-1,-1,0,1027.6701,482.30508)" + id="g5650-2-0-4-3" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172-9-8" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-58" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-28-7" + width="210.17955" + height="35.209244" + x="400.85385" + y="357.98779" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="505.94363" + y="379.78381" + id="text5371-2-32-8" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-27-1" + x="505.94363" + y="379.78381">previously_existed</tspan></text> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:2.73499846;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-1-5" + width="218.52127" + height="34.993004" + x="396.68301" + y="440.37622" + rx="12.372616" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="506.2796" + y="463.83755" + id="text5371-43-2" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-3-9" + x="506.2796" + y="463.83755">404 not found</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="528.75421" + y="422.69736" + id="text5371-2-8-9" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-3-4" + x="528.75421" + y="422.69736">false</tspan></text> + <g + transform="translate(563.72619,187.85116)" + id="g5650-2-2-17"> + <path + inkscape:connector-curvature="0" + id="path5570-2-1-0" + d="m -57.78256,343.20394 0,61.59661" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-5-45" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="matrix(0,-1,-1,0,1027.4933,646.81763)" + id="g5650-2-0-4-3-8-0-3" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172-9-8-9-31-8" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-58-6-3-6" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-8-9" + width="210.17955" + height="35.209244" + x="400.85385" + y="523.02966" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="505.45535" + y="544.82568" + id="text5371-2-74-0" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-18-2" + x="505.45535" + y="544.82568">moved_permanently</tspan></text> + <g + transform="matrix(0,-1,-1,0,347.00351,567.35686)" + id="g5650-2-0-4-3-8-9" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172-9-8-9-3" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-58-6-1" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:2.73499846;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-1" + width="218.52127" + height="34.993004" + x="396.68301" + y="275.81555" + rx="12.372616" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="506.2796" + y="297.7261" + id="text5371-43" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-3" + x="506.2796" + y="297.7261">412 precondition failed</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="668.11926" + y="463.37662" + id="text5371-4-3-9-8" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-62-9-9" + x="668.11926" + y="463.37662">true</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="549.12921" + y="587.59863" + id="text5371-4-4-9-3" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-2-6-2" + x="549.12921" + y="587.59863">true*</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="651.74426" + y="628.87946" + id="text5371-2-391-5-5-1" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-63-7-9-9" + x="651.74426" + y="628.87946">false</tspan></text> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:2.73499846;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-1-5-9" + width="218.52127" + height="34.993004" + x="396.68301" + y="605.41809" + rx="12.372616" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="505.57257" + y="627.32867" + id="text5371-43-2-9" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-3-9-7" + x="505.57257" + y="627.32867">301 moved permanently</tspan></text> + <g + transform="translate(563.72619,353.12604)" + id="g5650-2-2-65"> + <path + inkscape:connector-curvature="0" + id="path5570-2-1-5" + d="m -57.78256,343.20394 0,61.59661" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-5-5" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="matrix(0,-1,-1,0,1032.2004,811.50699)" + id="g5650-2-0-4-3-8-0-3-7" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172-9-8-9-31-8-1" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-58-6-3-6-3" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-8-9-1" + width="210.17955" + height="35.209244" + x="400.85385" + y="687.83093" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="505.45535" + y="709.62695" + id="text5371-2-74-0-7" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-18-2-8" + x="505.45535" + y="709.62695">moved_temporarily</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="549.12921" + y="752.64056" + id="text5371-4-4-9-3-2" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-2-6-2-6" + x="549.12921" + y="752.64056">true*</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="651.74426" + y="794.16199" + id="text5371-2-391-5-5-1-0" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-63-7-9-9-2" + x="651.74426" + y="794.16199">false</tspan></text> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:2.73499846;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-1-5-9-2" + width="218.52127" + height="34.993004" + x="396.68301" + y="770.70062" + rx="12.372616" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="505.57257" + y="792.61121" + id="text5371-43-2-9-7" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-3-9-7-8" + x="505.57257" + y="792.61121">307 moved temporarily</tspan></text> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:2.73499846;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-1-5-9-2-4" + width="218.52127" + height="34.993004" + x="396.68301" + y="853.22168" + rx="12.372616" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="505.97882" + y="874.99164" + id="text5371-43-2-9-7-3" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-3-9-7-8-7" + x="505.97882" + y="874.99164">410 gone</tspan></text> + <g + transform="translate(31.619614,4.2328831)" + id="g5650-2-2-6"> + <path + inkscape:connector-curvature="0" + id="path5570-2-1-6" + d="m -57.78256,343.20394 0,61.59661" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-5-1" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="178.57137" + y="505.21829" + id="text5371-4-6-0" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-0-9" + x="178.57137" + y="505.21829">false</tspan></text> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:2.73499846;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-1-8-7" + width="218.52127" + height="34.993004" + x="99.803589" + y="522.89716" + rx="12.372616" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="209.20485" + y="544.80774" + id="text5371-43-3-1" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-3-1-5" + x="209.20485" + y="544.80774">202 accepted</tspan></text> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:2.73499846;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-1-8-5" + width="218.52127" + height="34.993004" + x="99.803589" + y="687.69843" + rx="12.372616" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="208.6736" + y="711.01917" + id="text5371-43-3-9" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-3-1-8" + x="208.6736" + y="711.01917">204 no content</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="47.338913" + y="711.15979" + id="text5371-4-6-0-4" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-0-9-4" + x="47.338913" + y="711.15979">true</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="30.901413" + y="545.89758" + id="text5371-2-391-6" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-63-9" + x="30.901413" + y="545.89758">true</tspan></text> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:2.73499846;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-1-8-7-1" + width="218.52127" + height="34.993004" + x="99.803589" + y="357.85529" + rx="12.372616" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="208.45485" + y="381.31662" + id="text5371-43-3-1-2" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-3-1-5-9" + x="208.45485" + y="381.31662">500 internal server error</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="159.54012" + y="340.17645" + id="text5371-2-8-9-0" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-3-4-4" + x="159.54012" + y="340.17645">false</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="47.338913" + y="380.85568" + id="text5371-4-4-9-2" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-2-6-1" + x="47.338913" + y="380.85568">true</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="159.54012" + y="670.13989" + id="text5371-2-391-6-3" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-63-9-1" + x="159.54012" + y="670.13989">false</tspan></text> + </g> +</svg> diff --git a/docs/en/cowboy/2.0/guide/rest_flowcharts.asciidoc b/docs/en/cowboy/2.0/guide/rest_flowcharts.asciidoc new file mode 100644 index 00000000..b5697825 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/rest_flowcharts.asciidoc @@ -0,0 +1,248 @@ +[[rest_flowcharts]] +== REST flowcharts + +This chapter will explain the REST handler state machine through +a number of different diagrams. + +There are four main paths that requests may follow. One for the +method OPTIONS; one for the methods GET and HEAD; one for the +methods PUT, POST and PATCH; and one for the method DELETE. + +All paths start with the "Start" diagram, and all paths excluding +the OPTIONS path go through the "Content negotiation" diagram +and optionally the "Conditional requests" diagram if the resource +exists. + +The red squares refer to another diagram. The light green squares +indicate a response. Other squares may be either a callback or a +question answered by Cowboy itself. Green arrows tend to indicate +the default behavior if the callback is undefined. + +=== Start + +All requests start from here. + +image::rest_start.png[REST starting flowchart] + +A series of callbacks are called in succession to perform +a general checkup of the service, the request line and +request headers. + +The request body, if any, is not expected to have been +received for any of these steps. It is only processed +at the end of the "PUT, POST and PATCH methods" diagram, +when all conditions have been met. + +The `known_methods` and `allowed_methods` callbacks +return a list of methods. Cowboy then checks if the request +method is in the list, and stops otherwise. + +The `is_authorized` callback may be used to check that +access to the resource is authorized. Authentication +may also be performed as needed. When authorization is +denied, the return value from the callback must include +a challenge applicable to the requested resource, which +will be sent back to the client in the www-authenticate +header. + +This diagram is immediately followed by either the +"OPTIONS method" diagram when the request method is +OPTIONS, or the "Content negotiation" diagram otherwise. + +=== OPTIONS method + +This diagram only applies to OPTIONS requests. + +image::rest_options.png[REST OPTIONS method flowchart] + +The `options` callback may be used to add information +about the resource, such as media types or languages +provided; allowed methods; any extra information. A +response body may also be set, although clients should +not be expected to read it. + +If the `options` callback is not defined, Cowboy will +send a response containing the list of allowed methods +by default. + +=== Content negotiation + +This diagram applies to all request methods other than +OPTIONS. It is executed right after the "Start" diagram +is completed. + +image::rest_conneg.png[REST content negotiation flowchart] + +The purpose of these steps is to determine an appropriate +representation to be sent back to the client. + +The request may contain any of the accept header; the +accept-language header; or the accept-charset header. +When present, Cowboy will parse the headers and then +call the corresponding callback to obtain the list +of provided content-type, language or charset for this +resource. It then automatically select the best match +based on the request. + +If a callback is not defined, Cowboy will select the +content-type, language or charset that the client +prefers. + +The `content_types_provided` also returns the name of +a callback for every content-type it accepts. This +callback will only be called at the end of the +"GET and HEAD methods" diagram, when all conditions +have been met. + +The selected content-type, language and charset are +saved as meta values in the Req object. You *should* +use the appropriate representation if you set a +response body manually (alongside an error code, +for example). + +This diagram is immediately followed by +the "GET and HEAD methods" diagram, +the "PUT, POST and PATCH methods" diagram, +or the "DELETE method" diagram, depending on the +method. + +=== GET and HEAD methods + +This diagram only applies to GET and HEAD requests. + +For a description of the `cond` step, please see +the "Conditional requests" diagram. + +image::rest_get_head.png[REST GET/HEAD methods flowchart] + +When the resource exists, and the conditional steps +succeed, the resource can be retrieved. + +Cowboy prepares the response by first retrieving +metadata about the representation, then by calling +the `ProvideResource` callback. This is the callback +you defined for each content-types you returned from +`content_types_provided`. This callback returns the body +that will be sent back to the client, or a fun if the +body must be streamed. + +When the resource does not exist, Cowboy will figure out +whether the resource existed previously, and if so whether +it was moved elsewhere in order to redirect the client to +the new URI. + +The `moved_permanently` and `moved_temporarily` callbacks +must return the new location of the resource if it was in +fact moved. + +=== PUT, POST and PATCH methods + +This diagram only applies to PUT, POST and PATCH requests. + +For a description of the `cond` step, please see +the "Conditional requests" diagram. + +image::rest_put_post_patch.png[REST PUT/POST/PATCH methods flowchart] + +When the resource exists, first the conditional steps +are executed. When that succeeds, and the method is PUT, +Cowboy will call the `is_conflict` callback. This function +can be used to prevent potential race conditions, by locking +the resource for example. + +Then all three methods reach the `content_types_accepted` +step that we will describe in a few paragraphs. + +When the resource does not exist, and the method is PUT, +Cowboy will check for conflicts and then move on to the +`content_types_accepted` step. For other methods, Cowboy +will figure out whether the resource existed previously, +and if so whether it was moved elsewhere. If the resource +is truly non-existent, the method is POST and the call +for `allow_missing_post` returns `true`, then Cowboy will +move on to the `content_types_accepted` step. Otherwise +the request processing ends there. + +The `moved_permanently` and `moved_temporarily` callbacks +must return the new location of the resource if it was in +fact moved. + +The `content_types_accepted` returns a list of +content-types it accepts, but also the name of a callback +for each of them. Cowboy will select the appropriate +callback for processing the request body and call it. + +This callback may return one of three different return +values. + +If an error occurred while processing the request body, +it must return `false` and Cowboy will send an +appropriate error response. + +If the method is POST, then you may return `true` with +an URI of where the resource has been created. This is +especially useful for writing handlers for collections. + +Otherwise, return `true` to indicate success. Cowboy +will select the appropriate response to be sent depending +on whether a resource has been created, rather than +modified, and on the availability of a location header +or a body in the response. + +=== DELETE method + +This diagram only applies to DELETE requests. + +For a description of the `cond` step, please see +the "Conditional requests" diagram. + +image::rest_delete.png[REST DELETE method flowchart] + +When the resource exists, and the conditional steps +succeed, the resource can be deleted. + +Deleting the resource is a two steps process. First +the callback `delete_resource` is executed. Use this +callback to delete the resource. + +Because the resource may be cached, you must also +delete all cached representations of this resource +in the system. This operation may take a while though, +so you may return before it finished. + +Cowboy will then call the `delete_completed` callback. +If you know that the resource has been completely +deleted from your system, including from caches, then +you can return `true`. If any doubts persist, return +`false`. Cowboy will assume `true` by default. + +To finish, Cowboy checks if you set a response body, +and depending on that, sends the appropriate response. + +When the resource does not exist, Cowboy will figure out +whether the resource existed previously, and if so whether +it was moved elsewhere in order to redirect the client to +the new URI. + +The `moved_permanently` and `moved_temporarily` callbacks +must return the new location of the resource if it was in +fact moved. + +=== Conditional requests + +This diagram applies to all request methods other than +OPTIONS. It is executed right after the `resource_exists` +callback, when the resource exists. + +image::rest_cond.png[REST conditional requests flowchart] + +A request becomes conditional when it includes either of +the if-match header; the if-unmodified-since header; the +if-none-match header; or the if-modified-since header. + +If the condition fails, the request ends immediately +without any retrieval or modification of the resource. + +The `generate_etag` and `last_modified` are called as +needed. Cowboy will only call them once and then cache +the results for subsequent use. diff --git a/docs/en/cowboy/2.0/guide/rest_flowcharts/index.html b/docs/en/cowboy/2.0/guide/rest_flowcharts/index.html new file mode 100644 index 00000000..c5ca894b --- /dev/null +++ b/docs/en/cowboy/2.0/guide/rest_flowcharts/index.html @@ -0,0 +1,380 @@ +<!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"> + + <meta name="generator" content="Hugo 0.15" /> + + <title>Nine Nines: REST flowcharts</title> + + <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'> + + <link href="/css/bootstrap.min.css" rel="stylesheet"> + <link href="/css/99s.css" 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="Keep in touch!" href="http://twitter.com/lhoguin"><img src="/img/ico_microblog.png" data-hover="/img/ico_microblog_alt.png"></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>REST flowcharts</span></h1> + +<div class="paragraph"><p>This chapter will explain the REST handler state machine through
+a number of different diagrams.</p></div>
+<div class="paragraph"><p>There are four main paths that requests may follow. One for the
+method OPTIONS; one for the methods GET and HEAD; one for the
+methods PUT, POST and PATCH; and one for the method DELETE.</p></div>
+<div class="paragraph"><p>All paths start with the "Start" diagram, and all paths excluding
+the OPTIONS path go through the "Content negotiation" diagram
+and optionally the "Conditional requests" diagram if the resource
+exists.</p></div>
+<div class="paragraph"><p>The red squares refer to another diagram. The light green squares
+indicate a response. Other squares may be either a callback or a
+question answered by Cowboy itself. Green arrows tend to indicate
+the default behavior if the callback is undefined.</p></div>
+<div class="sect1">
+<h2 id="_start">Start</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>All requests start from here.</p></div>
+<div class="imageblock">
+<div class="content">
+<img src="../rest_start.png" alt="REST starting flowchart" />
+</div>
+</div>
+<div class="paragraph"><p>A series of callbacks are called in succession to perform
+a general checkup of the service, the request line and
+request headers.</p></div>
+<div class="paragraph"><p>The request body, if any, is not expected to have been
+received for any of these steps. It is only processed
+at the end of the "PUT, POST and PATCH methods" diagram,
+when all conditions have been met.</p></div>
+<div class="paragraph"><p>The <code>known_methods</code> and <code>allowed_methods</code> callbacks
+return a list of methods. Cowboy then checks if the request
+method is in the list, and stops otherwise.</p></div>
+<div class="paragraph"><p>The <code>is_authorized</code> callback may be used to check that
+access to the resource is authorized. Authentication
+may also be performed as needed. When authorization is
+denied, the return value from the callback must include
+a challenge applicable to the requested resource, which
+will be sent back to the client in the www-authenticate
+header.</p></div>
+<div class="paragraph"><p>This diagram is immediately followed by either the
+"OPTIONS method" diagram when the request method is
+OPTIONS, or the "Content negotiation" diagram otherwise.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_options_method">OPTIONS method</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>This diagram only applies to OPTIONS requests.</p></div>
+<div class="imageblock">
+<div class="content">
+<img src="../rest_options.png" alt="REST OPTIONS method flowchart" />
+</div>
+</div>
+<div class="paragraph"><p>The <code>options</code> callback may be used to add information
+about the resource, such as media types or languages
+provided; allowed methods; any extra information. A
+response body may also be set, although clients should
+not be expected to read it.</p></div>
+<div class="paragraph"><p>If the <code>options</code> callback is not defined, Cowboy will
+send a response containing the list of allowed methods
+by default.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_content_negotiation">Content negotiation</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>This diagram applies to all request methods other than
+OPTIONS. It is executed right after the "Start" diagram
+is completed.</p></div>
+<div class="imageblock">
+<div class="content">
+<img src="../rest_conneg.png" alt="REST content negotiation flowchart" />
+</div>
+</div>
+<div class="paragraph"><p>The purpose of these steps is to determine an appropriate
+representation to be sent back to the client.</p></div>
+<div class="paragraph"><p>The request may contain any of the accept header; the
+accept-language header; or the accept-charset header.
+When present, Cowboy will parse the headers and then
+call the corresponding callback to obtain the list
+of provided content-type, language or charset for this
+resource. It then automatically select the best match
+based on the request.</p></div>
+<div class="paragraph"><p>If a callback is not defined, Cowboy will select the
+content-type, language or charset that the client
+prefers.</p></div>
+<div class="paragraph"><p>The <code>content_types_provided</code> also returns the name of
+a callback for every content-type it accepts. This
+callback will only be called at the end of the
+"GET and HEAD methods" diagram, when all conditions
+have been met.</p></div>
+<div class="paragraph"><p>The selected content-type, language and charset are
+saved as meta values in the Req object. You <strong>should</strong>
+use the appropriate representation if you set a
+response body manually (alongside an error code,
+for example).</p></div>
+<div class="paragraph"><p>This diagram is immediately followed by
+the "GET and HEAD methods" diagram,
+the "PUT, POST and PATCH methods" diagram,
+or the "DELETE method" diagram, depending on the
+method.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_get_and_head_methods">GET and HEAD methods</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>This diagram only applies to GET and HEAD requests.</p></div>
+<div class="paragraph"><p>For a description of the <code>cond</code> step, please see
+the "Conditional requests" diagram.</p></div>
+<div class="imageblock">
+<div class="content">
+<img src="../rest_get_head.png" alt="REST GET/HEAD methods flowchart" />
+</div>
+</div>
+<div class="paragraph"><p>When the resource exists, and the conditional steps
+succeed, the resource can be retrieved.</p></div>
+<div class="paragraph"><p>Cowboy prepares the response by first retrieving
+metadata about the representation, then by calling
+the <code>ProvideResource</code> callback. This is the callback
+you defined for each content-types you returned from
+<code>content_types_provided</code>. This callback returns the body
+that will be sent back to the client, or a fun if the
+body must be streamed.</p></div>
+<div class="paragraph"><p>When the resource does not exist, Cowboy will figure out
+whether the resource existed previously, and if so whether
+it was moved elsewhere in order to redirect the client to
+the new URI.</p></div>
+<div class="paragraph"><p>The <code>moved_permanently</code> and <code>moved_temporarily</code> callbacks
+must return the new location of the resource if it was in
+fact moved.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_put_post_and_patch_methods">PUT, POST and PATCH methods</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>This diagram only applies to PUT, POST and PATCH requests.</p></div>
+<div class="paragraph"><p>For a description of the <code>cond</code> step, please see
+the "Conditional requests" diagram.</p></div>
+<div class="imageblock">
+<div class="content">
+<img src="../rest_put_post_patch.png" alt="REST PUT/POST/PATCH methods flowchart" />
+</div>
+</div>
+<div class="paragraph"><p>When the resource exists, first the conditional steps
+are executed. When that succeeds, and the method is PUT,
+Cowboy will call the <code>is_conflict</code> callback. This function
+can be used to prevent potential race conditions, by locking
+the resource for example.</p></div>
+<div class="paragraph"><p>Then all three methods reach the <code>content_types_accepted</code>
+step that we will describe in a few paragraphs.</p></div>
+<div class="paragraph"><p>When the resource does not exist, and the method is PUT,
+Cowboy will check for conflicts and then move on to the
+<code>content_types_accepted</code> step. For other methods, Cowboy
+will figure out whether the resource existed previously,
+and if so whether it was moved elsewhere. If the resource
+is truly non-existent, the method is POST and the call
+for <code>allow_missing_post</code> returns <code>true</code>, then Cowboy will
+move on to the <code>content_types_accepted</code> step. Otherwise
+the request processing ends there.</p></div>
+<div class="paragraph"><p>The <code>moved_permanently</code> and <code>moved_temporarily</code> callbacks
+must return the new location of the resource if it was in
+fact moved.</p></div>
+<div class="paragraph"><p>The <code>content_types_accepted</code> returns a list of
+content-types it accepts, but also the name of a callback
+for each of them. Cowboy will select the appropriate
+callback for processing the request body and call it.</p></div>
+<div class="paragraph"><p>This callback may return one of three different return
+values.</p></div>
+<div class="paragraph"><p>If an error occurred while processing the request body,
+it must return <code>false</code> and Cowboy will send an
+appropriate error response.</p></div>
+<div class="paragraph"><p>If the method is POST, then you may return <code>true</code> with
+an URI of where the resource has been created. This is
+especially useful for writing handlers for collections.</p></div>
+<div class="paragraph"><p>Otherwise, return <code>true</code> to indicate success. Cowboy
+will select the appropriate response to be sent depending
+on whether a resource has been created, rather than
+modified, and on the availability of a location header
+or a body in the response.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_delete_method">DELETE method</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>This diagram only applies to DELETE requests.</p></div>
+<div class="paragraph"><p>For a description of the <code>cond</code> step, please see
+the "Conditional requests" diagram.</p></div>
+<div class="imageblock">
+<div class="content">
+<img src="../rest_delete.png" alt="REST DELETE method flowchart" />
+</div>
+</div>
+<div class="paragraph"><p>When the resource exists, and the conditional steps
+succeed, the resource can be deleted.</p></div>
+<div class="paragraph"><p>Deleting the resource is a two steps process. First
+the callback <code>delete_resource</code> is executed. Use this
+callback to delete the resource.</p></div>
+<div class="paragraph"><p>Because the resource may be cached, you must also
+delete all cached representations of this resource
+in the system. This operation may take a while though,
+so you may return before it finished.</p></div>
+<div class="paragraph"><p>Cowboy will then call the <code>delete_completed</code> callback.
+If you know that the resource has been completely
+deleted from your system, including from caches, then
+you can return <code>true</code>. If any doubts persist, return
+<code>false</code>. Cowboy will assume <code>true</code> by default.</p></div>
+<div class="paragraph"><p>To finish, Cowboy checks if you set a response body,
+and depending on that, sends the appropriate response.</p></div>
+<div class="paragraph"><p>When the resource does not exist, Cowboy will figure out
+whether the resource existed previously, and if so whether
+it was moved elsewhere in order to redirect the client to
+the new URI.</p></div>
+<div class="paragraph"><p>The <code>moved_permanently</code> and <code>moved_temporarily</code> callbacks
+must return the new location of the resource if it was in
+fact moved.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_conditional_requests">Conditional requests</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>This diagram applies to all request methods other than
+OPTIONS. It is executed right after the <code>resource_exists</code>
+callback, when the resource exists.</p></div>
+<div class="imageblock">
+<div class="content">
+<img src="../rest_cond.png" alt="REST conditional requests flowchart" />
+</div>
+</div>
+<div class="paragraph"><p>A request becomes conditional when it includes either of
+the if-match header; the if-unmodified-since header; the
+if-none-match header; or the if-modified-since header.</p></div>
+<div class="paragraph"><p>If the condition fails, the request ends immediately
+without any retrieval or modification of the resource.</p></div>
+<div class="paragraph"><p>The <code>generate_etag</code> and <code>last_modified</code> are called as
+needed. Cowboy will only call them once and then cache
+the results for subsequent use.</p></div>
+</div>
+</div>
+ + + +</div> + +<div class="span3 sidecol"> + + +<h3> + Cowboy + 2.0 + + User Guide +</h3> + +<ul> + + <li><a href="/docs/en/cowboy/2.0/guide">User Guide</a></li> + + + <li><a href="/docs/en/cowboy/2.0/manual">Function Reference</a></li> + + +</ul> + +<h4 id="docs-nav">Navigation</h4> + +<h4>Version select</h4> +<ul> + + + + <li><a href="/docs/en/cowboy/1.0/guide">1.0</a></li> + + <li><a href="/docs/en/cowboy/2.0/guide">2.0</a></li> + +</ul> + +</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 © Loïc Hoguin 2012-2016</p> + </div> + </div> + </div> + </footer> + + + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> + <script src="/js/bootstrap-carousel.js"></script> + <script src="/js/bootstrap-dropdown.js"></script> + <script src="/js/custom.js"></script> + </body> +</html> + + diff --git a/docs/en/cowboy/2.0/guide/rest_get_head.png b/docs/en/cowboy/2.0/guide/rest_get_head.png Binary files differnew file mode 100644 index 00000000..efee892a --- /dev/null +++ b/docs/en/cowboy/2.0/guide/rest_get_head.png diff --git a/docs/en/cowboy/2.0/guide/rest_get_head.svg b/docs/en/cowboy/2.0/guide/rest_get_head.svg new file mode 100644 index 00000000..c78e9399 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/rest_get_head.svg @@ -0,0 +1,1523 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:osb="http://www.openswatchbook.org/uri/2009/osb" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="744.09448819" + height="1052.3622047" + id="svg2" + version="1.1" + inkscape:version="0.48.4 r9939" + sodipodi:docname="rest_get_head.svg" + inkscape:export-filename="/home/essen/Dropbox/Public/drawing.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90"> + <defs + id="defs4"> + <linearGradient + id="linearGradient5265"> + <stop + style="stop-color:#69d2e7;stop-opacity:1;" + offset="0" + id="stop5267" /> + <stop + style="stop-color:#69d2e7;stop-opacity:0.58823532;" + offset="1" + id="stop5269" /> + </linearGradient> + <linearGradient + id="linearGradient5251"> + <stop + style="stop-color:#69d2e7;stop-opacity:0.78431374;" + offset="0" + id="stop5253" /> + <stop + id="stop5263" + offset="0.5" + style="stop-color:#69d2e7;stop-opacity:1;" /> + <stop + style="stop-color:#69d2e7;stop-opacity:0.39215687;" + offset="1" + id="stop5255" /> + </linearGradient> + <linearGradient + id="linearGradient5233" + osb:paint="solid"> + <stop + style="stop-color:#69d2e7;stop-opacity:1;" + offset="0" + id="stop5235" /> + </linearGradient> + </defs> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="1" + inkscape:pageshadow="2" + inkscape:zoom="1.4142136" + inkscape:cx="122.28875" + inkscape:cy="777.29526" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="false" + inkscape:window-width="2560" + inkscape:window-height="1402" + inkscape:window-x="0" + inkscape:window-y="38" + inkscape:window-maximized="1" + inkscape:snap-global="true" + showguides="true"> + <inkscape:grid + type="xygrid" + id="grid5357" + empspacing="5" + visible="true" + enabled="true" + snapvisiblegridlinesonly="true" /> + </sodipodi:namedview> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title></dc:title> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1"> + <path + inkscape:export-ydpi="89.926643" + inkscape:export-xdpi="89.926643" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:connector-curvature="0" + id="use5777" + d="m -360.31658,371.70113 203.00246,0.045" + style="fill:none;stroke:#6d8e41;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:1.99999999, 3.99999998;stroke-dashoffset:0" /> + <g + transform="translate(416.63925,-305.0045)" + id="g5650-7" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-9" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-0" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(270.88515,-59.451492)" + id="g5650-0" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-5" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-1" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(270.88515,22.975441)" + id="g5650-94" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-71" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-5" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(270.88515,105.29639)" + id="g5650-93" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-3" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-4" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(270.88515,187.81342)" + id="g5650-3" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-93" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-04" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(270.88515,270.7128)" + id="g5650-6" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-78" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-9" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(270.88515,-141.93971)" + id="g5650-0-8" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-5-3" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-1-1" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-28" + width="210.17955" + height="35.209244" + x="108.01281" + y="275.4668" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-5" + width="210.17955" + height="35.209244" + x="108.01281" + y="357.98779" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-8" + width="210.17955" + height="35.209244" + x="108.01281" + y="440.50873" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-4" + width="210.17955" + height="35.209244" + x="108.01281" + y="523.02966" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <g + transform="matrix(0,-1,1,0,-314.06239,730.23773)" + id="g5650-2-0-4-8" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172-9-5" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-2" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-87" + width="210.17955" + height="35.209244" + x="108.01281" + y="605.5506" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <g + transform="matrix(0.70710678,-0.70710678,0.70710678,0.70710678,261.76354,-143.71473)" + id="g5650-2-2-8"> + <path + inkscape:connector-curvature="0" + id="path5570-2-1-4" + d="m -57.78256,343.20394 0,61.59661" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-5-3" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1" + width="210.17955" + height="35.209244" + x="253.76691" + y="112.69559" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <g + id="g5650" + transform="translate(0,-0.47597102)"> + <path + inkscape:connector-curvature="0" + id="path5570" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273" + width="104.5895" + height="36.392323" + x="-224.02068" + y="29.41218" + rx="15" /> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7" + width="104.5895" + height="36.392323" + x="-224.02068" + y="90.691978" + rx="15" /> + <rect + style="fill:#ffc48c;fill-opacity:1;fill-rule:nonzero;stroke:#d79c64;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-2" + width="104.5895" + height="36.392323" + x="-224.02068" + y="151.97169" + rx="15" /> + <rect + style="fill:#ff9f80;fill-opacity:1;fill-rule:nonzero;stroke:#d77758;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-22" + width="104.5895" + height="36.392323" + x="-224.02068" + y="213.25146" + rx="15" /> + <rect + style="fill:#f56991;fill-opacity:1;fill-rule:nonzero;stroke:#cd4169;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-8" + width="104.5895" + height="36.392323" + x="-224.02068" + y="274.53128" + rx="15" /> + <use + x="0" + y="0" + xlink:href="#rect5273-22" + id="use5355" + transform="translate(530.58261,-183.7816)" + width="744.09448" + height="1052.3622" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="-58.692513" + y="114.39204" + id="text5371" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373" + x="-58.692513" + y="114.39204">some text</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="-58.692513" + y="53.112247" + id="text5371-2" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-6" + x="-58.692513" + y="53.112247">some text</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="213.07524" + y="379.78381" + id="text5371-2-3" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-7" + x="213.07524" + y="379.78381">last_modified</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="212.74321" + y="546.59912" + id="text5371-2-3-0" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-7-3" + x="212.74321" + y="546.59912">ProvideResource</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="-58.692513" + y="236.95154" + id="text5371-4" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-9" + x="-58.692513" + y="236.95154">some text</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="359.14185" + y="50.482433" + id="text5371-4-0" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + x="359.14185" + y="50.482433" + id="tspan17171">conneg</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="212.77055" + y="627.34662" + id="text5371-2-9" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-8" + x="212.77055" + y="627.34662">multiple_choices</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="358.52466" + y="134.49161" + id="text5371-2-95" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-80" + x="358.52466" + y="134.49161">resource_exists</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="213.38774" + y="296.80188" + id="text5371-2-32" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-27" + x="213.38774" + y="296.80188">generate_etag</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="213.05571" + y="462.5274" + id="text5371-2-74" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-18" + x="213.05571" + y="462.5274">expires</tspan></text> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-2" + width="210.17955" + height="35.209244" + x="-489.75586" + y="33.4944" + rx="15" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="251.83722" + y="175.92931" + id="text5371-2-391" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-63" + x="251.83722" + y="175.92931">true</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="161.54012" + y="670.38055" + id="text5371-2-8" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-3" + x="161.54012" + y="670.38055">false</tspan></text> + <g + transform="matrix(0,-1,1,0,-513.31414,353.05561)" + id="g5650-2"> + <path + inkscape:connector-curvature="0" + id="path5570-2" + d="m -57.78256,275.13761 0,129.13992" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="447.26678" + y="176.39024" + id="text5371-4-6" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-0" + x="447.26678" + y="176.39024">false</tspan></text> + <g + transform="translate(563.72619,-141.76777)" + id="g5650-2-2"> + <path + inkscape:connector-curvature="0" + id="path5570-2-1" + d="m -57.78256,343.20394 0,61.59661" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-5" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:2.44279909;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5367" + width="207.05719" + height="171.55719" + x="-373.52859" + y="458.58362" + rx="11.072577" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="-544.69421" + y="-354.17184" + id="text5371-2-3-0-7" + sodipodi:linespacing="125%" + transform="matrix(0,-1,1,0,0,0)" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-7-3-9" + x="-544.69421" + y="-354.17184">middlewares</tspan></text> + <g + transform="matrix(0,-1,1,0,-508.93096,565.23553)" + id="g5650-2-0-4" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172-9" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="46.409981" + y="711.18011" + id="text5371-4-3-9" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-62-9" + x="46.409981" + y="711.18011">true</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="545.12921" + y="257.43518" + id="text5371-4-4-9" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-2-6" + x="545.12921" + y="257.43518">true</tspan></text> + <g + transform="matrix(0.70710678,0.70710678,-0.70710678,0.70710678,547.47379,-62.310424)" + id="g5650-9-9" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-7-6" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-09-5" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <use + x="0" + y="0" + xlink:href="#rect5273-22" + id="use5355-0" + transform="translate(384.82851,-20.897068)" + width="744.09448" + height="1052.3622" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="213.38774" + y="216.5154" + id="text5371-4-0-8" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + x="213.38774" + y="216.5154" + id="tspan17171-6">cond</tspan></text> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:2.73499846;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-1-1" + width="218.52127" + height="34.993004" + x="103.84195" + y="770.70062" + rx="12.372616" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="212.88774" + y="792.61121" + id="text5371-43-5" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-3-62" + x="212.88774" + y="792.61121">300 multiple choices</tspan></text> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:2.73499846;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-1-8" + width="218.52127" + height="34.993004" + x="103.84195" + y="688.17969" + rx="12.372616" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="212.35258" + y="711.50043" + id="text5371-43-3" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-3-1" + x="212.35258" + y="711.50043">200 OK</tspan></text> + <g + transform="matrix(0,-1,-1,0,1028.2004,317.70407)" + id="g5650-2-0-4-3-8" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172-9-8-9" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-58-6" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-28-4" + width="210.17955" + height="35.209244" + x="400.85385" + y="192.94594" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="505.77957" + y="216.51541" + id="text5371-2-32-6" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-27-8" + x="505.77957" + y="216.51541">has if-match?</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="651.74426" + y="299.27689" + id="text5371-2-391-5" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-63-7" + x="651.74426" + y="299.27689">false</tspan></text> + <g + transform="translate(563.72619,22.800669)" + id="g5650-0-6" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-5-7" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-1-3" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="matrix(0,-1,-1,0,1027.6701,482.30508)" + id="g5650-2-0-4-3" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172-9-8" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-58" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-28-7" + width="210.17955" + height="35.209244" + x="400.85385" + y="357.98779" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="505.94363" + y="379.78381" + id="text5371-2-32-8" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-27-1" + x="505.94363" + y="379.78381">previously_existed</tspan></text> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:2.73499846;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-1-5" + width="218.52127" + height="34.993004" + x="396.68301" + y="440.37622" + rx="12.372616" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="506.2796" + y="463.83755" + id="text5371-43-2" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-3-9" + x="506.2796" + y="463.83755">404 not found</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="528.75421" + y="422.69736" + id="text5371-2-8-9" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-3-4" + x="528.75421" + y="422.69736">false</tspan></text> + <g + transform="translate(563.72619,187.85116)" + id="g5650-2-2-17"> + <path + inkscape:connector-curvature="0" + id="path5570-2-1-0" + d="m -57.78256,343.20394 0,61.59661" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-5-45" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="matrix(0,-1,-1,0,1027.4933,646.81763)" + id="g5650-2-0-4-3-8-0-3" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172-9-8-9-31-8" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-58-6-3-6" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-8-9" + width="210.17955" + height="35.209244" + x="400.85385" + y="523.02966" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="505.45535" + y="544.82568" + id="text5371-2-74-0" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-18-2" + x="505.45535" + y="544.82568">moved_permanently</tspan></text> + <g + transform="matrix(0,-1,-1,0,347.00351,567.35686)" + id="g5650-2-0-4-3-8-9" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172-9-8-9-3" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-58-6-1" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:2.73499846;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-1" + width="218.52127" + height="34.993004" + x="396.68301" + y="275.81555" + rx="12.372616" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="506.2796" + y="297.7261" + id="text5371-43" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-3" + x="506.2796" + y="297.7261">412 precondition failed</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="668.11926" + y="463.37662" + id="text5371-4-3-9-8" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-62-9-9" + x="668.11926" + y="463.37662">true</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="549.12921" + y="587.59863" + id="text5371-4-4-9-3" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-2-6-2" + x="549.12921" + y="587.59863">true*</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="651.74426" + y="628.87946" + id="text5371-2-391-5-5-1" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-63-7-9-9" + x="651.74426" + y="628.87946">false</tspan></text> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:2.73499846;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-1-5-9" + width="218.52127" + height="34.993004" + x="396.68301" + y="605.41809" + rx="12.372616" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="505.57257" + y="627.32867" + id="text5371-43-2-9" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-3-9-7" + x="505.57257" + y="627.32867">301 moved permanently</tspan></text> + <g + transform="translate(563.72619,353.12604)" + id="g5650-2-2-65"> + <path + inkscape:connector-curvature="0" + id="path5570-2-1-5" + d="m -57.78256,343.20394 0,61.59661" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-5-5" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="matrix(0,-1,-1,0,1032.2004,811.50699)" + id="g5650-2-0-4-3-8-0-3-7" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172-9-8-9-31-8-1" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-58-6-3-6-3" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-8-9-1" + width="210.17955" + height="35.209244" + x="400.85385" + y="687.83093" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="505.45535" + y="709.62695" + id="text5371-2-74-0-7" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-18-2-8" + x="505.45535" + y="709.62695">moved_temporarily</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="549.12921" + y="752.64056" + id="text5371-4-4-9-3-2" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-2-6-2-6" + x="549.12921" + y="752.64056">true*</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="651.74426" + y="794.16199" + id="text5371-2-391-5-5-1-0" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-63-7-9-9-2" + x="651.74426" + y="794.16199">false</tspan></text> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:2.73499846;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-1-5-9-2" + width="218.52127" + height="34.993004" + x="396.68301" + y="770.70062" + rx="12.372616" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="505.57257" + y="792.61121" + id="text5371-43-2-9-7" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-3-9-7-8" + x="505.57257" + y="792.61121">307 moved temporarily</tspan></text> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:2.73499846;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-1-5-9-2-4" + width="218.52127" + height="34.993004" + x="396.68301" + y="853.22168" + rx="12.372616" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="505.97882" + y="874.99164" + id="text5371-43-2-9-7-3" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-3-9-7-8-7" + x="505.97882" + y="874.99164">410 gone</tspan></text> + <g + transform="translate(31.619614,4.2328831)" + id="g5650-2-2-6"> + <path + inkscape:connector-curvature="0" + id="path5570-2-1-6" + d="m -57.78256,343.20394 0,61.59661" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-5-1" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + </g> +</svg> diff --git a/docs/en/cowboy/2.0/guide/rest_handlers.asciidoc b/docs/en/cowboy/2.0/guide/rest_handlers.asciidoc new file mode 100644 index 00000000..6bff18d7 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/rest_handlers.asciidoc @@ -0,0 +1,133 @@ +[[rest_handlers]] +== REST handlers + +REST is implemented in Cowboy as a sub protocol. The request +is handled as a state machine with many optional callbacks +describing the resource and modifying the machine's behavior. + +The REST handler is the recommended way to handle HTTP requests. + +=== Initialization + +First, the `init/2` callback is called. This callback is common +to all handlers. To use REST for the current request, this function +must return a `cowboy_rest` tuple. + +[source,erlang] +---- +init(Req, _Opts) -> + {cowboy_rest, Req, #state{}}. +---- + +Cowboy will then switch to the REST protocol and start executing +the state machine. + +After reaching the end of the flowchart, the `terminate/3` callback +will be called if it is defined. + +=== Methods + +The REST component has code for handling the following HTTP methods: +HEAD, GET, POST, PATCH, PUT, DELETE and OPTIONS. + +Other methods can be accepted, however they have no specific callback +defined for them at this time. + +=== Callbacks + +All callbacks are optional. Some may become mandatory depending +on what other defined callbacks return. The various flowcharts +in the next chapter should be a useful to determine which callbacks +you need. + +All callbacks take two arguments, the Req object and the State, +and return a three-element tuple of the form `{Value, Req, State}`. + +All callbacks can also return `{stop, Req, State}` to stop execution +of the request. + +The following table summarizes the callbacks and their default values. +If the callback isn't defined, then the default value will be used. +Please look at the flowcharts to find out the result of each return +value. + +In the following table, "skip" means the callback is entirely skipped +if it is undefined, moving directly to the next step. Similarly, +"none" means there is no default value for this callback. + +[cols="<,^",options="header"] +|=== +| Callback name | Default value +| allowed_methods | `[<<"GET">>, <<"HEAD">>, <<"OPTIONS">>]` +| allow_missing_post | `true` +| charsets_provided | skip +| content_types_accepted | none +| content_types_provided | `$$[{{<<"text">>, <<"html">>, '*'}, to_html}]$$` +| delete_completed | `true` +| delete_resource | `false` +| expires | `undefined` +| forbidden | `false` +| generate_etag | `undefined` +| is_authorized | `true` +| is_conflict | `false` +| known_methods | `[<<"GET">>, <<"HEAD">>, <<"POST">>, <<"PUT">>, <<"PATCH">>, <<"DELETE">>, <<"OPTIONS">>]` +| languages_provided | skip +| last_modified | `undefined` +| malformed_request | `false` +| moved_permanently | `false` +| moved_temporarily | `false` +| multiple_choices | `false` +| options | `ok` +| previously_existed | `false` +| resource_exists | `true` +| service_available | `true` +| uri_too_long | `false` +| valid_content_headers | `true` +| valid_entity_length | `true` +| variances | `[]` +|=== + +As you can see, Cowboy tries to move on with the request whenever +possible by using well thought out default values. + +In addition to these, there can be any number of user-defined +callbacks that are specified through `content_types_accepted/2` +and `content_types_provided/2`. They can take any name, however +it is recommended to use a separate prefix for the callbacks of +each function. For example, `from_html` and `to_html` indicate +in the first case that we're accepting a resource given as HTML, +and in the second case that we send one as HTML. + +=== Meta data + +Cowboy will set informative meta values at various points of the +execution. You can retrieve them using `cowboy_req:meta/{2,3}`. +The values are defined in the following table. + +[cols="<,<",options="header"] +|=== +| Meta key | Details +| media_type | The content-type negotiated for the response entity. +| language | The language negotiated for the response entity. +| charset | The charset negotiated for the response entity. +|=== + +They can be used to send a proper body with the response to a +request that used a method other than HEAD or GET. + +=== Response headers + +Cowboy will set response headers automatically over the execution +of the REST code. They are listed in the following table. + +[cols="<,<",options="header"] +|=== +| Header name | Details +| content-language | Language used in the response body +| content-type | Media type and charset of the response body +| etag | Etag of the resource +| expires | Expiration date of the resource +| last-modified | Last modification date for the resource +| location | Relative or absolute URI to the requested resource +| vary | List of headers that may change the representation of the resource +|=== diff --git a/docs/en/cowboy/2.0/guide/rest_handlers/index.html b/docs/en/cowboy/2.0/guide/rest_handlers/index.html new file mode 100644 index 00000000..15282e5f --- /dev/null +++ b/docs/en/cowboy/2.0/guide/rest_handlers/index.html @@ -0,0 +1,231 @@ +<!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"> + + <meta name="generator" content="Hugo 0.15" /> + + <title>Nine Nines: REST handlers</title> + + <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'> + + <link href="/css/bootstrap.min.css" rel="stylesheet"> + <link href="/css/99s.css" 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="Keep in touch!" href="http://twitter.com/lhoguin"><img src="/img/ico_microblog.png" data-hover="/img/ico_microblog_alt.png"></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>REST handlers</span></h1> + +<div class="paragraph"><p>REST is implemented in Cowboy as a sub protocol. The request
+is handled as a state machine with many optional callbacks
+describing the resource and modifying the machine’s behavior.</p></div>
+<div class="paragraph"><p>The REST handler is the recommended way to handle HTTP requests.</p></div>
+<div class="sect1">
+<h2 id="_initialization">Initialization</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>First, the <code>init/2</code> callback is called. This callback is common
+to all handlers. To use REST for the current request, this function
+must return a <code>cowboy_rest</code> tuple.</p></div>
+<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">init</span></span>(<span style="color: #009900">Req</span>, <span style="color: #009900">_Opts</span>) <span style="color: #990000">-></span>
+ {<span style="color: #FF6600">cowboy_rest</span>, <span style="color: #009900">Req</span>, <span style="color: #008080">#state</span>{}}<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Cowboy will then switch to the REST protocol and start executing
+the state machine.</p></div>
+<div class="paragraph"><p>After reaching the end of the flowchart, the <code>terminate/3</code> callback
+will be called if it is defined.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_methods">Methods</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>The REST component has code for handling the following HTTP methods:
+HEAD, GET, POST, PATCH, PUT, DELETE and OPTIONS.</p></div>
+<div class="paragraph"><p>Other methods can be accepted, however they have no specific callback
+defined for them at this time.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_callbacks">Callbacks</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>All callbacks are optional. Some may become mandatory depending
+on what other defined callbacks return. The various flowcharts
+in the next chapter should be a useful to determine which callbacks
+you need.</p></div>
+<div class="paragraph"><p>All callbacks take two arguments, the Req object and the State,
+and return a three-element tuple of the form <code>{Value, Req, State}</code>.</p></div>
+<div class="paragraph"><p>All callbacks can also return <code>{stop, Req, State}</code> to stop execution
+of the request.</p></div>
+<div class="paragraph"><p>The following table summarizes the callbacks and their default values.
+If the callback isn’t defined, then the default value will be used.
+Please look at the flowcharts to find out the result of each return
+value.</p></div>
+<div class="paragraph"><p>In the following table, "skip" means the callback is entirely skipped
+if it is undefined, moving directly to the next step. Similarly,
+"none" means there is no default value for this callback.</p></div>
+<div class="tableblock">
+<table rules="all"
+width="100%"
+frame="border"
+cellspacing="0" cellpadding="4">
+<col width="50%" />
+<col width="50%" />
+<thead>
+<tr>
+<th align="left" valign="top"> Callback name </th>
+<th align="center" valign="top"> Default value</th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td align="left" valign="top"><p class="table">allowed_methods</p></td>
+<td align="center" valign="top"><p class="table"><code>[<<"GET">>, <<"HEAD">>, <<"OPTIONS">>]</code></p></td>
+</tr>
+<tr>
+<td align="left" valign="top"><p class="table">allow_missing_post</p></td>
+<td align="center" valign="top"><p class="table"><code>true</code></p></td>
+</tr>
+<tr>
+<td align="left" valign="top"><p class="table">charsets_provided</p></td>
+<td align="center" valign="top"><p class="table">skip</p></td>
+</tr>
+<tr>
+<td align="left" valign="top"><p class="table">content_types_accepted</p></td>
+<td align="center" valign="top"><p class="table">none</p></td>
+</tr>
+<tr>
+<td align="left" valign="top"><p class="table">content_types_provided</p></td>
+<td align="center" valign="top"><p class="table">`$$[</p></td>
+</tr>
+</tbody>
+</table>
+</div>
+</div>
+</div>
+ + + +</div> + +<div class="span3 sidecol"> + + +<h3> + Cowboy + 2.0 + + User Guide +</h3> + +<ul> + + <li><a href="/docs/en/cowboy/2.0/guide">User Guide</a></li> + + + <li><a href="/docs/en/cowboy/2.0/manual">Function Reference</a></li> + + +</ul> + +<h4 id="docs-nav">Navigation</h4> + +<h4>Version select</h4> +<ul> + + + + <li><a href="/docs/en/cowboy/1.0/guide">1.0</a></li> + + <li><a href="/docs/en/cowboy/2.0/guide">2.0</a></li> + +</ul> + +</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 © Loïc Hoguin 2012-2016</p> + </div> + </div> + </div> + </footer> + + + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> + <script src="/js/bootstrap-carousel.js"></script> + <script src="/js/bootstrap-dropdown.js"></script> + <script src="/js/custom.js"></script> + </body> +</html> + + diff --git a/docs/en/cowboy/2.0/guide/rest_options.png b/docs/en/cowboy/2.0/guide/rest_options.png Binary files differnew file mode 100644 index 00000000..90fd6f06 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/rest_options.png diff --git a/docs/en/cowboy/2.0/guide/rest_options.svg b/docs/en/cowboy/2.0/guide/rest_options.svg new file mode 100644 index 00000000..496c050c --- /dev/null +++ b/docs/en/cowboy/2.0/guide/rest_options.svg @@ -0,0 +1,387 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:osb="http://www.openswatchbook.org/uri/2009/osb" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="744.09448819" + height="1052.3622047" + id="svg2" + version="1.1" + inkscape:version="0.48.4 r9939" + sodipodi:docname="rest_options.svg" + inkscape:export-filename="/home/essen/Dropbox/Public/drawing.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90"> + <defs + id="defs4"> + <linearGradient + id="linearGradient5265"> + <stop + style="stop-color:#69d2e7;stop-opacity:1;" + offset="0" + id="stop5267" /> + <stop + style="stop-color:#69d2e7;stop-opacity:0.58823532;" + offset="1" + id="stop5269" /> + </linearGradient> + <linearGradient + id="linearGradient5251"> + <stop + style="stop-color:#69d2e7;stop-opacity:0.78431374;" + offset="0" + id="stop5253" /> + <stop + id="stop5263" + offset="0.5" + style="stop-color:#69d2e7;stop-opacity:1;" /> + <stop + style="stop-color:#69d2e7;stop-opacity:0.39215687;" + offset="1" + id="stop5255" /> + </linearGradient> + <linearGradient + id="linearGradient5233" + osb:paint="solid"> + <stop + style="stop-color:#69d2e7;stop-opacity:1;" + offset="0" + id="stop5235" /> + </linearGradient> + </defs> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="1" + inkscape:pageshadow="2" + inkscape:zoom="1.0000001" + inkscape:cx="166.77748" + inkscape:cy="548.36436" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="false" + inkscape:window-width="2560" + inkscape:window-height="1402" + inkscape:window-x="0" + inkscape:window-y="38" + inkscape:window-maximized="1" + inkscape:snap-global="true" + showguides="true"> + <inkscape:grid + type="xygrid" + id="grid5357" + empspacing="5" + visible="true" + enabled="true" + snapvisiblegridlinesonly="true" /> + </sodipodi:namedview> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title /> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1"> + <path + inkscape:export-ydpi="89.926643" + inkscape:export-xdpi="89.926643" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:connector-curvature="0" + id="use5777" + d="m -360.31658,371.70113 203.00246,0.045" + style="fill:none;stroke:#6d8e41;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:1.99999999, 3.99999998;stroke-dashoffset:0" /> + <g + transform="translate(205.92143,-296.03137)" + id="g5650-7"> + <path + inkscape:connector-curvature="0" + id="path5570-9" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-0" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(205.92143,-212.00698)" + id="g5650-9"> + <path + inkscape:connector-curvature="0" + id="path5570-7" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-09" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-28" + width="210.17955" + height="35.209244" + x="43.049091" + y="204.67757" + rx="15" /> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1" + width="210.17955" + height="35.209244" + x="43.049091" + y="121.0042" + rx="15" /> + <g + id="g5650" + transform="translate(0,-0.47597102)"> + <path + inkscape:connector-curvature="0" + id="path5570" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273" + width="104.5895" + height="36.392323" + x="-224.02068" + y="29.41218" + rx="15" /> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7" + width="104.5895" + height="36.392323" + x="-224.02068" + y="90.691978" + rx="15" /> + <rect + style="fill:#ffc48c;fill-opacity:1;fill-rule:nonzero;stroke:#d79c64;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-2" + width="104.5895" + height="36.392323" + x="-224.02068" + y="151.97169" + rx="15" /> + <rect + style="fill:#ff9f80;fill-opacity:1;fill-rule:nonzero;stroke:#d77758;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-22" + width="104.5895" + height="36.392323" + x="-224.02068" + y="213.25146" + rx="15" /> + <rect + style="fill:#f56991;fill-opacity:1;fill-rule:nonzero;stroke:#cd4169;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-8" + width="104.5895" + height="36.392323" + x="-224.02068" + y="274.53128" + rx="15" /> + <use + x="0" + y="0" + xlink:href="#rect5273-22" + id="use5355" + transform="translate(319.86479,-176.50006)" + width="744.09448" + height="1052.3622" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="-58.692513" + y="114.39204" + id="text5371" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373" + x="-58.692513" + y="114.39204">some text</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="-58.692513" + y="53.112247" + id="text5371-2" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-6" + x="-58.692513" + y="53.112247">some text</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="-58.692513" + y="236.95154" + id="text5371-4" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-9" + x="-58.692513" + y="236.95154">some text</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="147.00391" + y="60.912468" + id="text5371-4-0" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + x="147.00391" + y="60.912468" + id="tspan17171">start</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="148.13106" + y="142.80627" + id="text5371-2-95" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-6-80" + x="148.13106" + y="142.80627">options</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="147.80684" + y="226.4736" + id="text5371-2-32" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-6-27" + x="147.80684" + y="226.4736">200 OK</tspan></text> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-2" + width="210.17955" + height="35.209244" + x="-489.75586" + y="33.4944" + rx="15" /> + <g + transform="matrix(0,-1,1,0,-513.31414,353.05561)" + id="g5650-2"> + <path + inkscape:connector-curvature="0" + id="path5570-2" + d="m -57.78256,275.13761 0,129.13992" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:2.44279909;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5367" + width="207.05719" + height="171.55719" + x="-373.52859" + y="458.58362" + rx="11.072577" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="-544.69421" + y="-354.17184" + id="text5371-2-3-0-7" + sodipodi:linespacing="125%" + transform="matrix(0,-1,1,0,0,0)" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-7-3-9" + x="-544.69421" + y="-354.17184">middlewares</tspan></text> + </g> +</svg> diff --git a/docs/en/cowboy/2.0/guide/rest_principles.asciidoc b/docs/en/cowboy/2.0/guide/rest_principles.asciidoc new file mode 100644 index 00000000..66939cb7 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/rest_principles.asciidoc @@ -0,0 +1,160 @@ +[[rest_principles]] +== REST principles + +This chapter will attempt to define the concepts behind REST +and explain what makes a service RESTful. + +REST is often confused with performing a distinct operation +depending on the HTTP method, while using more than the GET +and POST methods. That's highly misguided at best. + +We will first attempt to define REST and will look at what +it means in the context of HTTP and the Web. +For a more in-depth explanation of REST, you can read +http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm[Roy T. Fielding's dissertation] +as it does a great job explaining where it comes from and +what it achieves. + +=== REST architecture + +REST is a *client-server* architecture. The client and the server +both have a different set of concerns. The server stores and/or +manipulates information and makes it available to the user in +an efficient manner. The client takes that information and +displays it to the user and/or uses it to perform subsequent +requests for information. This separation of concerns allows both +the client and the server to evolve independently as it only +requires that the interface stays the same. + +REST is *stateless*. That means the communication between the +client and the server always contains all the information needed +to perform the request. There is no session state in the server, +it is kept entirely on the client's side. If access to a resource +requires authentication, then the client needs to authenticate +itself with every request. + +REST is *cacheable*. The client, the server and any intermediary +components can all cache resources in order to improve performance. + +REST provides a *uniform interface* between components. This +simplifies the architecture, as all components follow the same +rules to speak to one another. It also makes it easier to understand +the interactions between the different components of the system. +A number of constraints are required to achieve this. They are +covered in the rest of the chapter. + +REST is a *layered system*. Individual components cannot see +beyond the immediate layer with which they are interacting. This +means that a client connecting to an intermediate component, like +a proxy, has no knowledge of what lies beyond. This allows +components to be independent and thus easily replaceable or +extendable. + +REST optionally provides *code on demand*. Code may be downloaded +to extend client functionality. This is optional however because +the client may not be able to download or run this code, and so +a REST component cannot rely on it being executed. + +=== Resources and resource identifiers + +A resource is an abstract concept. In a REST system, any information +that can be named may be a resource. This includes documents, images, +a collection of resources and any other information. Any information +that can be the target of an hypertext link can be a resource. + +A resource is a conceptual mapping to a set of entities. The set of +entities evolves over time; a resource doesn't. For example, a resource +can map to "users who have logged in this past month" and another +to "all users". At some point in time they may map to the same set of +entities, because all users logged in this past month. But they are +still different resources. Similarly, if nobody logged in recently, +then the first resource may map to the empty set. This resource exists +regardless of the information it maps to. + +Resources are identified by uniform resource identifiers, also known +as URIs. Sometimes internationalized resource identifiers, or IRIs, +may also be used, but these can be directly translated into a URI. + +In practice we will identify two kinds of resources. Individual +resources map to a set of one element, for example "user Joe". +Collection of resources map to a set of 0 to N elements, +for example "all users". + +=== Resource representations + +The representation of a resource is a sequence of bytes associated +with metadata. + +The metadata comes as a list of key-value pairs, where the name +corresponds to a standard that defines the value's structure and +semantics. With HTTP, the metadata comes in the form of request +or response headers. The headers' structure and semantics are well +defined in the HTTP standard. Metadata includes representation +metadata, resource metadata and control data. + +The representation metadata gives information about the +representation, such as its media type, the date of last +modification, or even a checksum. + +Resource metadata could be link to related resources or +information about additional representations of the resource. + +Control data allows parameterizing the request or response. +For example, we may only want the representation returned if +it is more recent than the one we have in cache. Similarly, +we may want to instruct the client about how it should cache +the representation. This isn't restricted to caching. We may, +for example, want to store a new representation of a resource +only if it wasn't modified since we first retrieved it. + +The data format of a representation is also known as the media +type. Some media types are intended for direct rendering to the +user, while others are intended for automated processing. The +media type is a key component of the REST architecture. + +=== Self-descriptive messages + +Messages must be self-descriptive. That means that the data +format of a representation must always come with its media +type (and similarly requesting a resource involves choosing +the media type of the representation returned). If you are +sending HTML, then you must say it is HTML by sending the +media type with the representation. In HTTP this is done +using the content-type header. + +The media type is often an IANA registered media type, like +`text/html` or `image/png`, but does not need to be. Exactly +two things are important for respecting this constraint: that +the media type is well specified, and that the sender and +recipient agree about what the media type refers to. + +This means that you can create your own media types, like +`application/x-mine`, and that as long as you write the +specifications for it and that both endpoints agree about +it then the constraint is respected. + +=== Hypermedia as the engine of application state + +The last constraint is generally where services that claim +to be RESTful fail. Interactions with a server must be +entirely driven by hypermedia. The client does not need +any prior knowledge of the service in order to use it, +other than an entry point and of course basic understanding +of the media type of the representations, at the very least +enough to find and identify hyperlinks and link relations. + +To give a simple example, if your service only works with +the `application/json` media type then this constraint +cannot be respected (as there are no concept of links in +JSON) and thus your service isn't RESTful. This is the case +for the majority of self-proclaimed REST services. + +On the other hand if you create a JSON based media type +that has a concept of links and link relations, then +your service might be RESTful. + +Respecting this constraint means that the entirety of the +service becomes self-discoverable, not only the resources +in it, but also the operations you can perform on it. This +makes clients very thin as there is no need to implement +anything specific to the service to operate on it. diff --git a/docs/en/cowboy/2.0/guide/rest_principles/index.html b/docs/en/cowboy/2.0/guide/rest_principles/index.html new file mode 100644 index 00000000..1b4335dd --- /dev/null +++ b/docs/en/cowboy/2.0/guide/rest_principles/index.html @@ -0,0 +1,289 @@ +<!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"> + + <meta name="generator" content="Hugo 0.15" /> + + <title>Nine Nines: REST principles</title> + + <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'> + + <link href="/css/bootstrap.min.css" rel="stylesheet"> + <link href="/css/99s.css" 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="Keep in touch!" href="http://twitter.com/lhoguin"><img src="/img/ico_microblog.png" data-hover="/img/ico_microblog_alt.png"></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>REST principles</span></h1> + +<div class="paragraph"><p>This chapter will attempt to define the concepts behind REST
+and explain what makes a service RESTful.</p></div>
+<div class="paragraph"><p>REST is often confused with performing a distinct operation
+depending on the HTTP method, while using more than the GET
+and POST methods. That’s highly misguided at best.</p></div>
+<div class="paragraph"><p>We will first attempt to define REST and will look at what
+it means in the context of HTTP and the Web.
+For a more in-depth explanation of REST, you can read
+<a href="http://www.ics.uci.edu/~fielding/pubs/dissertation/top.htm">Roy T. Fielding’s dissertation</a>
+as it does a great job explaining where it comes from and
+what it achieves.</p></div>
+<div class="sect1">
+<h2 id="_rest_architecture">REST architecture</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>REST is a <strong>client-server</strong> architecture. The client and the server
+both have a different set of concerns. The server stores and/or
+manipulates information and makes it available to the user in
+an efficient manner. The client takes that information and
+displays it to the user and/or uses it to perform subsequent
+requests for information. This separation of concerns allows both
+the client and the server to evolve independently as it only
+requires that the interface stays the same.</p></div>
+<div class="paragraph"><p>REST is <strong>stateless</strong>. That means the communication between the
+client and the server always contains all the information needed
+to perform the request. There is no session state in the server,
+it is kept entirely on the client’s side. If access to a resource
+requires authentication, then the client needs to authenticate
+itself with every request.</p></div>
+<div class="paragraph"><p>REST is <strong>cacheable</strong>. The client, the server and any intermediary
+components can all cache resources in order to improve performance.</p></div>
+<div class="paragraph"><p>REST provides a <strong>uniform interface</strong> between components. This
+simplifies the architecture, as all components follow the same
+rules to speak to one another. It also makes it easier to understand
+the interactions between the different components of the system.
+A number of constraints are required to achieve this. They are
+covered in the rest of the chapter.</p></div>
+<div class="paragraph"><p>REST is a <strong>layered system</strong>. Individual components cannot see
+beyond the immediate layer with which they are interacting. This
+means that a client connecting to an intermediate component, like
+a proxy, has no knowledge of what lies beyond. This allows
+components to be independent and thus easily replaceable or
+extendable.</p></div>
+<div class="paragraph"><p>REST optionally provides <strong>code on demand</strong>. Code may be downloaded
+to extend client functionality. This is optional however because
+the client may not be able to download or run this code, and so
+a REST component cannot rely on it being executed.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_resources_and_resource_identifiers">Resources and resource identifiers</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>A resource is an abstract concept. In a REST system, any information
+that can be named may be a resource. This includes documents, images,
+a collection of resources and any other information. Any information
+that can be the target of an hypertext link can be a resource.</p></div>
+<div class="paragraph"><p>A resource is a conceptual mapping to a set of entities. The set of
+entities evolves over time; a resource doesn’t. For example, a resource
+can map to "users who have logged in this past month" and another
+to "all users". At some point in time they may map to the same set of
+entities, because all users logged in this past month. But they are
+still different resources. Similarly, if nobody logged in recently,
+then the first resource may map to the empty set. This resource exists
+regardless of the information it maps to.</p></div>
+<div class="paragraph"><p>Resources are identified by uniform resource identifiers, also known
+as URIs. Sometimes internationalized resource identifiers, or IRIs,
+may also be used, but these can be directly translated into a URI.</p></div>
+<div class="paragraph"><p>In practice we will identify two kinds of resources. Individual
+resources map to a set of one element, for example "user Joe".
+Collection of resources map to a set of 0 to N elements,
+for example "all users".</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_resource_representations">Resource representations</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>The representation of a resource is a sequence of bytes associated
+with metadata.</p></div>
+<div class="paragraph"><p>The metadata comes as a list of key-value pairs, where the name
+corresponds to a standard that defines the value’s structure and
+semantics. With HTTP, the metadata comes in the form of request
+or response headers. The headers' structure and semantics are well
+defined in the HTTP standard. Metadata includes representation
+metadata, resource metadata and control data.</p></div>
+<div class="paragraph"><p>The representation metadata gives information about the
+representation, such as its media type, the date of last
+modification, or even a checksum.</p></div>
+<div class="paragraph"><p>Resource metadata could be link to related resources or
+information about additional representations of the resource.</p></div>
+<div class="paragraph"><p>Control data allows parameterizing the request or response.
+For example, we may only want the representation returned if
+it is more recent than the one we have in cache. Similarly,
+we may want to instruct the client about how it should cache
+the representation. This isn’t restricted to caching. We may,
+for example, want to store a new representation of a resource
+only if it wasn’t modified since we first retrieved it.</p></div>
+<div class="paragraph"><p>The data format of a representation is also known as the media
+type. Some media types are intended for direct rendering to the
+user, while others are intended for automated processing. The
+media type is a key component of the REST architecture.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_self_descriptive_messages">Self-descriptive messages</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Messages must be self-descriptive. That means that the data
+format of a representation must always come with its media
+type (and similarly requesting a resource involves choosing
+the media type of the representation returned). If you are
+sending HTML, then you must say it is HTML by sending the
+media type with the representation. In HTTP this is done
+using the content-type header.</p></div>
+<div class="paragraph"><p>The media type is often an IANA registered media type, like
+<code>text/html</code> or <code>image/png</code>, but does not need to be. Exactly
+two things are important for respecting this constraint: that
+the media type is well specified, and that the sender and
+recipient agree about what the media type refers to.</p></div>
+<div class="paragraph"><p>This means that you can create your own media types, like
+<code>application/x-mine</code>, and that as long as you write the
+specifications for it and that both endpoints agree about
+it then the constraint is respected.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_hypermedia_as_the_engine_of_application_state">Hypermedia as the engine of application state</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>The last constraint is generally where services that claim
+to be RESTful fail. Interactions with a server must be
+entirely driven by hypermedia. The client does not need
+any prior knowledge of the service in order to use it,
+other than an entry point and of course basic understanding
+of the media type of the representations, at the very least
+enough to find and identify hyperlinks and link relations.</p></div>
+<div class="paragraph"><p>To give a simple example, if your service only works with
+the <code>application/json</code> media type then this constraint
+cannot be respected (as there are no concept of links in
+JSON) and thus your service isn’t RESTful. This is the case
+for the majority of self-proclaimed REST services.</p></div>
+<div class="paragraph"><p>On the other hand if you create a JSON based media type
+that has a concept of links and link relations, then
+your service might be RESTful.</p></div>
+<div class="paragraph"><p>Respecting this constraint means that the entirety of the
+service becomes self-discoverable, not only the resources
+in it, but also the operations you can perform on it. This
+makes clients very thin as there is no need to implement
+anything specific to the service to operate on it.</p></div>
+</div>
+</div>
+ + + +</div> + +<div class="span3 sidecol"> + + +<h3> + Cowboy + 2.0 + + User Guide +</h3> + +<ul> + + <li><a href="/docs/en/cowboy/2.0/guide">User Guide</a></li> + + + <li><a href="/docs/en/cowboy/2.0/manual">Function Reference</a></li> + + +</ul> + +<h4 id="docs-nav">Navigation</h4> + +<h4>Version select</h4> +<ul> + + + + <li><a href="/docs/en/cowboy/1.0/guide">1.0</a></li> + + <li><a href="/docs/en/cowboy/2.0/guide">2.0</a></li> + +</ul> + +</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 © Loïc Hoguin 2012-2016</p> + </div> + </div> + </div> + </footer> + + + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> + <script src="/js/bootstrap-carousel.js"></script> + <script src="/js/bootstrap-dropdown.js"></script> + <script src="/js/custom.js"></script> + </body> +</html> + + diff --git a/docs/en/cowboy/2.0/guide/rest_put_post_patch.png b/docs/en/cowboy/2.0/guide/rest_put_post_patch.png Binary files differnew file mode 100644 index 00000000..4afca9e9 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/rest_put_post_patch.png diff --git a/docs/en/cowboy/2.0/guide/rest_put_post_patch.svg b/docs/en/cowboy/2.0/guide/rest_put_post_patch.svg new file mode 100644 index 00000000..263cc942 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/rest_put_post_patch.svg @@ -0,0 +1,2856 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:osb="http://www.openswatchbook.org/uri/2009/osb" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="744.09448" + height="1052.3622" + id="svg2" + version="1.1" + inkscape:version="0.48.4 r9939" + sodipodi:docname="rest_put_post_patch.svg" + inkscape:export-filename="/home/essen/Dropbox/Public/drawing.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90"> + <defs + id="defs4"> + <linearGradient + id="linearGradient5265"> + <stop + style="stop-color:#69d2e7;stop-opacity:1;" + offset="0" + id="stop5267" /> + <stop + style="stop-color:#69d2e7;stop-opacity:0.58823532;" + offset="1" + id="stop5269" /> + </linearGradient> + <linearGradient + id="linearGradient5251"> + <stop + style="stop-color:#69d2e7;stop-opacity:0.78431374;" + offset="0" + id="stop5253" /> + <stop + id="stop5263" + offset="0.5" + style="stop-color:#69d2e7;stop-opacity:1;" /> + <stop + style="stop-color:#69d2e7;stop-opacity:0.39215687;" + offset="1" + id="stop5255" /> + </linearGradient> + <linearGradient + id="linearGradient5233" + osb:paint="solid"> + <stop + style="stop-color:#69d2e7;stop-opacity:1;" + offset="0" + id="stop5235" /> + </linearGradient> + </defs> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="1" + inkscape:pageshadow="2" + inkscape:zoom="2" + inkscape:cx="299.56028" + inkscape:cy="-395.99137" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="false" + inkscape:window-width="2560" + inkscape:window-height="1402" + inkscape:window-x="0" + inkscape:window-y="38" + inkscape:window-maximized="1" + inkscape:snap-global="true" + showguides="true"> + <inkscape:grid + type="xygrid" + id="grid5357" + empspacing="5" + visible="true" + enabled="true" + snapvisiblegridlinesonly="true" /> + </sodipodi:namedview> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title /> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1" + transform="translate(0,1.5472441e-4)"> + <path + inkscape:export-ydpi="89.926643" + inkscape:export-xdpi="89.926643" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:connector-curvature="0" + id="use5777" + d="m -360.31658,371.70113 203.00246,0.045" + style="fill:none;stroke:#6d8e41;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:1.99999999, 3.99999998;stroke-dashoffset:0" /> + <g + transform="translate(370.63925,-305.0045)" + id="g5650-7" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-9" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-0" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="matrix(0.70710678,-0.70710678,0.70710678,0.70710678,215.76354,-143.71473)" + id="g5650-2-2-8"> + <path + inkscape:connector-curvature="0" + id="path5570-2-1-4" + d="m -57.78256,343.20394 0,61.59661" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-5-3" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1" + width="210.17955" + height="35.209244" + x="207.76691" + y="112.69559" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <g + id="g5650" + transform="translate(229.41793,93.569228)"> + <path + inkscape:connector-curvature="0" + id="path5570" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273" + width="104.5895" + height="36.392323" + x="-224.02068" + y="29.41218" + rx="15" /> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7" + width="104.5895" + height="36.392323" + x="-224.02068" + y="90.691978" + rx="15" /> + <rect + style="fill:#ffc48c;fill-opacity:1;fill-rule:nonzero;stroke:#d79c64;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-2" + width="104.5895" + height="36.392323" + x="-224.02068" + y="151.97169" + rx="15" /> + <rect + style="fill:#ff9f80;fill-opacity:1;fill-rule:nonzero;stroke:#d77758;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-22" + width="104.5895" + height="36.392323" + x="-224.02068" + y="213.25146" + rx="15" /> + <rect + style="fill:#f56991;fill-opacity:1;fill-rule:nonzero;stroke:#cd4169;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-8" + width="104.5895" + height="36.392323" + x="-224.02068" + y="274.53128" + rx="15" /> + <use + x="0" + y="0" + xlink:href="#rect5273-22" + id="use5355" + transform="translate(484.58261,-183.7816)" + width="744.09448" + height="1052.3622" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="-58.692513" + y="114.39204" + id="text5371" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373" + x="-58.692513" + y="114.39204">some text</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="-58.692513" + y="53.112247" + id="text5371-2" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-6" + x="-58.692513" + y="53.112247">some text</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="-58.692513" + y="236.95154" + id="text5371-4" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-9" + x="-58.692513" + y="236.95154">some text</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="313.14185" + y="50.482433" + id="text5371-4-0" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + x="313.14185" + y="50.482433" + id="tspan17171">conneg</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="312.52466" + y="134.49161" + id="text5371-2-95" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-80" + x="312.52466" + y="134.49161">resource_exists</tspan></text> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-2" + width="210.17955" + height="35.209244" + x="-489.75586" + y="33.4944" + rx="15" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="205.83722" + y="175.92931" + id="text5371-2-391" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-63" + x="205.83722" + y="175.92931">true</tspan></text> + <g + transform="matrix(0,-1,1,0,-586.85324,629.53436)" + id="g5650-2"> + <path + inkscape:connector-curvature="0" + id="path5570-2" + d="m -57.78256,275.13761 0,129.13992" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="401.26678" + y="176.39024" + id="text5371-4-6" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-0" + x="401.26678" + y="176.39024">false</tspan></text> + <g + transform="translate(517.41793,-144.94975)" + id="g5650-2-2"> + <path + inkscape:connector-curvature="0" + id="path5570-2-1" + d="m -57.78256,343.20394 0,61.59661" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-5" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:2.44279909;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5367" + width="207.05719" + height="171.55719" + x="-373.52859" + y="458.58362" + rx="11.072577" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="-544.69421" + y="-354.17184" + id="text5371-2-3-0-7" + sodipodi:linespacing="125%" + transform="matrix(0,-1,1,0,0,0)" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-7-3-9" + x="-544.69421" + y="-354.17184">middlewares</tspan></text> + <g + transform="matrix(0,-1,1,0,-508.93096,565.23553)" + id="g5650-2-0-4" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172-9" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="496.12921" + y="255.81152" + id="text5371-4-4-9" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-2-6" + x="496.12921" + y="255.81152">true</tspan></text> + <g + transform="matrix(0.70710678,0.70710678,-0.70710678,0.70710678,501.47379,-62.310424)" + id="g5650-9-9" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-7-6" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-09-5" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="matrix(-0.08419269,-0.81571201,-1.0857893,-0.07785618,667.56845,424.75412)" + id="g5650-2-0-4-3-8-9-2" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <g + id="g6634"> + <path + inkscape:connector-curvature="0" + id="path20172-9-8-9-3-7" + d="m 18.652036,463.77088 c 0,0 65.81835,-170.39134 345.869384,-106.32083" + style="fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(-0.44664484,-0.38224114,-0.38224114,0.44664484,110.28192,145.11277)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-58-6-1-5-3-0" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <g + transform="matrix(0,-1,1,0,-443.10758,753.30201)" + id="g5650-2-0-4-3-8-9-0" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#6d8e41;stroke-width:1.98598707;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 530.36552,568.78955 c 0,0 -275.73145,-235.65993 -602.761737,-30.40772" + id="path20172-9-8-9-3-1" + inkscape:connector-curvature="0" /> + <path + transform="matrix(0.29887498,0.50623478,-0.50623478,0.29887498,210.13685,523.56774)" + inkscape:transform-center-y="-0.81224338" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-58-6-1-1" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="5.134315" /> + </g> + <use + x="0" + y="0" + xlink:href="#rect5273-22" + id="use5355-0" + transform="translate(343.36129,-20.897068)" + width="744.09448" + height="1052.3622" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="171.92052" + y="216.5154" + id="text5371-4-0-8" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + x="171.92052" + y="216.5154" + id="tspan17171-6">cond</tspan></text> + <g + transform="matrix(0,-1,-1,0,983.2611,313.28465)" + id="g5650-2-0-4-3-8" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172-9-8-9" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-58-6" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-28-4" + width="210.17955" + height="35.209244" + x="354.54559" + y="192.94588" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="459.47131" + y="216.51535" + id="text5371-2-32-6" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-27-8" + x="459.47131" + y="216.51535">has if-match?</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="609.12769" + y="296.02957" + id="text5371-2-391-5" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-63-7" + x="609.12769" + y="296.02957">false</tspan></text> + <g + transform="translate(517.41793,13.785058)" + id="g5650-0-6" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-5-7" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-1-3" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-28-7" + width="210.17955" + height="35.209244" + x="354.54559" + y="351.97443" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="459.47131" + y="374.91498" + id="text5371-2-32-8" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-27-1" + x="459.47131" + y="374.91498">method is POST/PATCH?</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="479.69171" + y="414.84009" + id="text5371-2-8-9" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-3-4" + x="479.69171" + y="414.84009">true</tspan></text> + <g + transform="translate(517.41793,490.80719)" + id="g5650-0-6-0" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-5-7-76" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-1-3-7" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="matrix(0.34202014,-0.93969262,-0.93969262,-0.34202014,1086.6042,1290.1092)" + id="g5650-2-0-4-0-6" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 152.42141,615.5283 c 0,0 -73.650807,-184.33554 -245.781275,54.61093" + id="path20172-9-3-4" + inkscape:connector-curvature="0" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,178.4823,610.19901)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-0-2" + style="opacity:0.80000000000000004;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <g + transform="translate(517.41793,570.7504)" + id="g5650-2-2-2-7-5"> + <path + inkscape:connector-curvature="0" + id="path5570-2-1-62-7-7" + d="m -57.78256,343.20394 0,61.59661" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-5-9-5-8" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-8-9" + width="210.17955" + height="35.209244" + x="354.54559" + y="908.57428" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <g + transform="matrix(0,1,-1,0,694.44282,904.44724)" + id="g5650-2-2-6-6"> + <path + inkscape:connector-curvature="0" + id="path5570-2-1-6-3" + d="m -57.78256,339.02801 0,65.70583" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-5-1-1" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-8-9-59" + width="210.17955" + height="35.209244" + x="354.54559" + y="829.06006" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="459.47131" + y="852.62952" + id="text5371-2-74-0" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-18-2" + x="459.47131" + y="852.62952">method is POST?</tspan></text> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:2.73499846;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-1" + width="218.52127" + height="34.993004" + x="350.37473" + y="272.56824" + rx="12.372616" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="459.97131" + y="294.47879" + id="text5371-43" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-3" + x="459.97131" + y="294.47879">412 precondition failed</tspan></text> + <g + transform="translate(2.6196148,3.2328831)" + id="g5650-2-2-6"> + <path + inkscape:connector-curvature="0" + id="path5570-2-1-6" + d="m -57.78256,343.20394 0,61.59661" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-5-1" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="matrix(0,1,-1,0,694.2803,507.19416)" + id="g5650-0-6-3" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-5-7-7" + d="m -57.78256,340.48769 0,63.05283" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-1-3-1" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(517.41793,93.25206)" + id="g5650-2-2-2"> + <path + inkscape:connector-curvature="0" + id="path5570-2-1-62" + d="m -57.78256,343.20394 0,61.59661" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-5-9" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-28-7-6" + width="210.17955" + height="35.209244" + x="354.54559" + y="431.48868" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="459.63538" + y="453.2847" + id="text5371-2-32-8-5" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-27-1-2" + x="459.63538" + y="453.2847">previously_existed</tspan></text> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:2.73499846;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-1-5-5" + width="218.52127" + height="34.993004" + x="62.374733" + y="590.76849" + rx="12.372616" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <g + transform="translate(229.41793,173.2314)" + id="g5650-2-2-2-7"> + <path + inkscape:connector-curvature="0" + id="path5570-2-1-62-7" + d="m -57.78256,343.20394 0,61.59661" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-5-9-5" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="171.97131" + y="614.22986" + id="text5371-43-2-8" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-3-9-74" + x="171.97131" + y="614.22986">404 not found</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="296.84631" + y="433.29703" + id="text5371-2-8-9-9" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-3-4-8" + x="296.84631" + y="433.29703">false</tspan></text> + <g + transform="translate(516.00372,173.10383)" + id="g5650-2-2-17-8"> + <path + inkscape:connector-curvature="0" + id="path5570-2-1-0-3" + d="m -57.78256,343.20394 0,61.59661" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-5-45-2" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="matrix(0,-1,-1,0,983.3517,631.45158)" + id="g5650-2-0-4-3-8-0-3-9" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172-9-8-9-31-8-9" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-58-6-3-6-5" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="500.12921" + y="574.2605" + id="text5371-4-4-9-3-4" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-2-6-2-8" + x="500.12921" + y="574.2605">true*</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="607.7135" + y="610.86951" + id="text5371-2-391-5-5-1-3" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-63-7-9-9-5" + x="607.7135" + y="610.86951">false</tspan></text> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:2.73499846;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-1-5-9-29" + width="218.52127" + height="34.993004" + x="350.37473" + y="590.76849" + rx="12.372616" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="459.26428" + y="612.67908" + id="text5371-43-2-9-4" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-3-9-7-5" + x="459.26428" + y="612.67908">301 moved permanently</tspan></text> + <g + transform="translate(517.41793,332.05687)" + id="g5650-2-2-65-2"> + <path + inkscape:connector-curvature="0" + id="path5570-2-1-5-9" + d="m -57.78256,343.20394 0,61.59661" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-5-5-9" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="matrix(0,-1,-1,0,982.4019,789.6002)" + id="g5650-2-0-4-3-8-0-3-7-9" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172-9-8-9-31-8-1-6" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-58-6-3-6-3-2" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-8-9-1-4" + width="210.17955" + height="35.209244" + x="354.54559" + y="670.03149" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="459.14709" + y="691.82751" + id="text5371-2-74-0-7-4" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-18-2-8-9" + x="459.14709" + y="691.82751">moved_temporarily</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="500.12921" + y="733.21747" + id="text5371-4-4-9-3-2-0" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-2-6-2-6-6" + x="500.12921" + y="733.21747">true*</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="607.7135" + y="769.89801" + id="text5371-2-391-5-5-1-0-7" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-63-7-9-9-2-8" + x="607.7135" + y="769.89801">false</tspan></text> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:2.73499846;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-1-5-9-2-1" + width="218.52127" + height="34.993004" + x="350.37473" + y="749.65387" + rx="12.372616" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="459.26428" + y="771.56445" + id="text5371-43-2-9-7-1" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-3-9-7-8-9" + x="459.26428" + y="771.56445">307 moved temporarily</tspan></text> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:2.73499846;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-1-5-9-2-4-1" + width="218.52127" + height="34.993004" + x="495.25732" + y="1220.3925" + rx="12.372616" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="604.32263" + y="1242.303" + id="text5371-43-2-9-7-3-8" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-3-9-7-8-7-5" + x="604.32263" + y="1242.303">400 bad request</tspan></text> + <g + transform="matrix(-0.34202014,-0.93969262,0.93969262,-0.34202014,-311.11659,1246.6148)" + id="g5650-2-0-4-0" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 251.64748,501.65559 c 0,0 -132.95279,-198.6035 -335.041098,15.43198" + id="path20172-9-3" + inkscape:connector-curvature="0" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,190.22636,455.7026)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-0" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="120.08566" + y="891.92566" + id="text5371-2-8-9-4" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-3-4-5" + x="120.08566" + y="891.92566">true</tspan></text> + <g + transform="matrix(0,-1,-1,0,699.22962,550.33236)" + id="g5650-2-0-4-5" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172-9-1" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-5" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-8-9-1-3" + width="210.17955" + height="35.209244" + x="66.545593" + y="511.00293" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="167.39459" + y="532.79895" + id="text5371-2-74-0-7-1" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-18-2-8-94" + x="167.39459" + y="532.79895">allow_missing_post</tspan></text> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-8-9-5" + width="210.17955" + height="35.209244" + x="66.545593" + y="431.80698" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="175.2144" + y="455.37643" + id="text5371-2-74-0-4" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-18-2-6" + x="175.2144" + y="455.37643">method is POST?</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="459.35022" + y="930.3703" + id="text5371-2-74-0-7-1-5" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-18-2-8-94-5" + x="459.35022" + y="930.3703">allow_missing_post</tspan></text> + <g + transform="translate(229.41793,490.95885)" + id="g5650-0-6-9" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-5-7-2" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-1-3-14" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-8-9-19" + width="210.17955" + height="35.209244" + x="66.545593" + y="829.06006" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="166.63885" + y="852.62952" + id="text5371-2-74-0-1" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-18-2-7" + x="166.63885" + y="852.62952">method is PUT?</tspan></text> + <g + transform="translate(229.41793,571.07045)" + id="g5650-2-2-65-9"> + <path + inkscape:connector-curvature="0" + id="path5570-2-1-5-1" + d="m -57.78256,343.20394 0,61.59661" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-5-5-3" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="matrix(-0.34202014,-0.93969262,-0.93969262,0.34202014,702.18987,886.11239)" + id="g5650-2-0-4-05" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#6d8e41;stroke-width:2.19573760000000018;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 96.51476,423.00572 c 0,0 -72.55269,-41.6703 -192.585744,26.04761" + id="path20172-9-9" + inkscape:connector-curvature="0" /> + <path + transform="matrix(0.20642765,0.55044303,-0.55044303,0.20642765,176.90073,487.11794)" + inkscape:transform-center-y="2.5699832" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-6" + style="opacity:0.80000000000000004;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="6.2547481" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-8-9-1-8" + width="210.17955" + height="35.209244" + x="66.545593" + y="908.57428" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="166.24431" + y="930.3703" + id="text5371-2-74-0-7-15" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-18-2-8-2" + x="166.24431" + y="930.3703">is_conflict</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="136.52316" + y="971.55994" + id="text5371-4-4-9-3-2-08" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-2-6-2-6-0" + x="136.52316" + y="971.55994">true</tspan></text> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:2.73499846;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-1-5-9-2-7" + width="218.52127" + height="34.993004" + x="62.374733" + y="988.43671" + rx="12.372616" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="171.44006" + y="1011.8981" + id="text5371-43-2-9-7-0" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-3-9-7-8-0" + x="171.44006" + y="1011.8981">409 conflict</tspan></text> + <g + transform="translate(370.63925,803.79161)" + id="g5650-93-7" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-3-0" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-4-9" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-8-9-1-40" + width="210.17955" + height="35.209244" + x="207.76691" + y="1142.3002" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="313.14185" + y="1164.0962" + id="text5371-2-74-0-7-41" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-18-2-8-3" + x="313.14185" + y="1164.0962">content_types_accepted</tspan></text> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-4-9" + width="210.17955" + height="35.209244" + x="207.76691" + y="1220.5249" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="313.21997" + y="1242.2975" + id="text5371-2-3-0-3" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-7-3-1" + x="313.21997" + y="1242.2975">AcceptResource</tspan></text> + <g + transform="translate(233.45629,961.91953)" + id="g5650-6-4-8-7" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-78-5-5-2" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-9-6-6-6" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="matrix(0,-1,1,0,-345.93614,1498.2457)" + id="g5650-2-0-4-8-9-6-0" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 169.94368,422.8286 c 0,0 -94.23585,-64.78987 -206.003937,-8.35999" + id="path20172-9-5-2-6-6" + inkscape:connector-curvature="0" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-2-8-7-6" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-8-9-19-2" + width="210.17955" + height="35.209244" + x="70.583946" + y="1300.3734" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="175.50966" + y="1323.8022" + id="text5371-2-74-0-1-3" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-18-2-7-4" + x="175.50966" + y="1323.8022">new resource?</tspan></text> + <g + transform="translate(517.41793,962.60627)" + id="g5650-6-4-8" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-78-5-5" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-9-6-6" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="matrix(0,-1,-1,0,985.5699,1417.4167)" + id="g5650-2-0-4-8-9-6" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172-9-5-2-6" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-2-8-7" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-8-9-19-2-1" + width="210.17955" + height="35.209244" + x="354.54559" + y="1300.3734" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="459.47131" + y="1323.8022" + id="text5371-2-74-0-1-3-4" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-18-2-7-4-8" + x="459.47131" + y="1323.8022">new resource?</tspan></text> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:2.73499846;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-1-8-7" + width="218.52127" + height="34.993004" + x="350.37473" + y="1380.1163" + rx="12.372616" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="459.776" + y="1403.5779" + id="text5371-43-3-2" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-3-1-9" + x="459.776" + y="1403.5779">201 created</tspan></text> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:2.73499846;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-1-8-7-4" + width="218.52127" + height="34.993004" + x="350.37473" + y="1459.7511" + rx="12.372616" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="459.03381" + y="1483.2128" + id="text5371-43-3-2-6" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-3-1-9-2" + x="459.03381" + y="1483.2128">303 see other</tspan></text> + <g + transform="matrix(0,1,1,0,-67.245042,1455.155)" + id="g5650-2-2-6-6-7-9-1"> + <path + inkscape:connector-curvature="0" + id="path5570-2-1-6-3-8-5-9" + d="m -57.78256,339.02801 0,65.70583" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-5-1-1-7-6-3" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(233.45629,1121.5376)" + id="g5650-6-4-8-7-7" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-78-5-5-2-8" + d="m -57.78256,294.4515 0,109.76214" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-9-6-6-6-7" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-8-9-19-2-2" + width="210.17955" + height="35.209244" + x="70.583946" + y="1379.7678" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="175.50966" + y="1401.7865" + id="text5371-2-74-0-1-3-7" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-18-2-7-4-9" + x="175.50966" + y="1401.7865">has resp location?</tspan></text> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:2.73499846;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-1-8-7-4-7" + width="218.52127" + height="34.993004" + x="62.374733" + y="1619.0205" + rx="12.372616" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <g + transform="translate(233.45629,1201.4108)" + id="g5650-6-4-8-8" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-78-5-5-3" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-9-6-6-3" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="matrix(0,1,1,0,-63.162935,1614.665)" + id="g5650-2-2-6-6-7-9"> + <path + inkscape:connector-curvature="0" + id="path5570-2-1-6-3-8-5" + d="m -57.78256,339.02801 0,65.70583" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-5-1-1-7-6" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-8-9-19-2-2-4" + width="210.17955" + height="35.209244" + x="70.583946" + y="1539.2778" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="175.50966" + y="1561.2965" + id="text5371-2-74-0-1-3-7-9" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-18-2-7-4-9-5" + x="175.50966" + y="1561.2965">has resp body?</tspan></text> + <g + transform="translate(517.41793,1201.395)" + id="g5650-6-4" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-78-5" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-9-6" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="matrix(0,-1,-1,0,987.64405,1658.4266)" + id="g5650-2-0-4-8-9" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172-9-5-2" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-2-8" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-87-8" + width="210.17955" + height="35.209244" + x="354.54559" + y="1539.2778" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="459.30334" + y="1561.0739" + id="text5371-2-9-6" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-8-6" + x="459.30334" + y="1561.0739">multiple_choices</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="479.75421" + y="1602.6646" + id="text5371-2-8-4" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-3-7" + x="479.75421" + y="1602.6646">false</tspan></text> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:2.73499846;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-1-1-0" + width="218.52127" + height="34.993004" + x="350.37473" + y="1698.6555" + rx="12.372616" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="459.42053" + y="1720.566" + id="text5371-43-5-7" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-3-62-9" + x="459.42053" + y="1720.566">300 multiple choices</tspan></text> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:2.73499846;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-1-8-3" + width="218.52127" + height="34.993004" + x="350.37473" + y="1619.0208" + rx="12.372616" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="458.88538" + y="1642.3412" + id="text5371-43-3-1" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-3-1-3" + x="458.88538" + y="1642.3412">200 OK</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="171.24475" + y="1642.3412" + id="text5371-43-3-2-6-9" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-3-1-9-2-0" + x="171.24475" + y="1642.3412">204 no content</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="479.69171" + y="891.92566" + id="text5371-2-8-9-1" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-3-4-1" + x="479.69171" + y="891.92566">true</tspan></text> + <g + id="g5650-4-8" + transform="matrix(0.5,0.8660254,-0.8660254,0.5,204.7918,279.30499)"> + <path + inkscape:connector-curvature="0" + id="path5570-8-7" + d="m -58.01975,316.62647 0,86.23385" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,72.919441,161.77521)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-3-4" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="496.12921" + y="494.3544" + id="text5371-4-4-9-1" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-2-6-8" + x="496.12921" + y="494.3544">true</tspan></text> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-8-9-1-3-4-8" + width="210.17955" + height="35.209244" + x="354.54559" + y="511.00293" + rx="15" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="459.14709" + y="532.79895" + id="text5371-2-74-0-9" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-18-2-9" + x="459.14709" + y="532.79895">moved_permanently</tspan></text> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:2.73499846;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-1-8-7-9" + width="218.52127" + height="34.993004" + x="350.37473" + y="988.43671" + rx="12.372616" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="459.67053" + y="1010.2067" + id="text5371-43-3-2-1" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-3-1-9-5" + x="459.67053" + y="1010.2067">410 gone</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="260.04547" + y="494.97446" + id="text5371-4-4-9-1-4" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-2-6-8-2" + x="260.04547" + y="494.97446">false</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="120.08566" + y="494.51349" + id="text5371-2-8-9-0" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-3-4-55" + x="120.08566" + y="494.51349">true</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="133.92941" + y="574.40112" + id="text5371-4-4-9-1-1" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-2-6-8-0" + x="133.92941" + y="574.40112">false</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="315.87756" + y="828.86047" + id="text5371-4-4-9-1-1-9" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-2-6-8-0-1" + x="315.87756" + y="828.86047">false</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="498.78546" + y="972.02087" + id="text5371-4-4-9-1-1-1" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-2-6-8-0-2" + x="498.78546" + y="972.02087">false</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="458.9295" + y="1217.7582" + id="text5371-4-4-9-1-1-9-1" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-2-6-8-0-1-2" + x="458.9295" + y="1217.7582">false</tspan></text> + <g + transform="matrix(0,1,1,0,77.85132,1295.6715)" + id="g5650-2-2-6-6-7"> + <path + inkscape:connector-curvature="0" + id="path5570-2-1-6-3-8" + d="m -57.78256,339.02801 0,65.70583" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-5-1-1-7" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="207.75119" + y="1283.5576" + id="text5371-2-391-8" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-63-4" + x="207.75119" + y="1283.5576">true</tspan></text> + <g + transform="matrix(0.70710678,0.70710678,-0.70710678,0.70710678,501.47379,1045.323)" + id="g5650-9-9-1" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-7-6-1" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-09-5-4" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:end;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:end;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="419.81369" + y="1283.0615" + id="text5371-2-391-9" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + x="419.81369" + y="1283.0615" + id="tspan5794">true, URI*</tspan></text> + <g + transform="matrix(-0.70710678,0.70710678,0.70710678,0.70710678,124.04665,1045.323)" + id="g5650-9-9-4" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + inkscape:connector-curvature="0" + id="path5570-7-6-8" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-09-5-45" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="479.69171" + y="1363.2994" + id="text5371-2-8-4-3" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-3-7-5" + x="479.69171" + y="1363.2994">true</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="626.74475" + y="1403.5779" + id="text5371-4-4-9-1-1-9-1-4" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-2-6-8-0-1-2-0" + x="626.74475" + y="1403.5779">false</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="624.0885" + y="1642.0209" + id="text5371-4-4-9-1-1-9-1-0" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-2-6-8-0-1-2-3" + x="624.0885" + y="1642.0209">true</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="317.91525" + y="1538.8624" + id="text5371-4-4-9-1-1-9-1-2" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-2-6-8-0-1-2-1" + x="317.91525" + y="1538.8624">true</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="190.83659" + y="1602.2036" + id="text5371-2-8-4-3-9" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-3-7-5-9" + x="190.83659" + y="1602.2036">false</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="190.83659" + y="1363.1792" + id="text5371-2-8-4-3-8" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-3-7-5-0" + x="190.83659" + y="1363.1792">true</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="7.9966321" + y="1443.395" + id="text5371-4-4-9-1-1-9-1-4-7" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-2-6-8-0-1-2-0-6" + x="7.9966321" + y="1443.395">false</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="317.86548" + y="1379.0562" + id="text5371-4-4-9-1-1-9-1-2-2" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-2-6-8-0-1-2-1-5" + x="317.86548" + y="1379.0562">true</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="190.83659" + y="1482.6313" + id="text5371-2-8-4-3-8-7" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-3-7-5-0-8" + x="190.83659" + y="1482.6313">false</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="85.095001" + y="891.92566" + id="text5371-4-4-9-1-4-2" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-2-6-8-2-9" + x="85.095001" + y="891.92566">false</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="232.21094" + y="971.55994" + id="text5371-2-391-5-5-1-0-7-1" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-63-7-9-9-2-8-8" + x="232.21094" + y="971.55994">false</tspan></text> + <g + transform="matrix(0,-1,1,0,-359.02432,626.75367)" + id="g5650-2-0-4-3-8-9-4" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <g + id="g6614"> + <g + inkscape:export-ydpi="89.926643" + inkscape:export-xdpi="89.926643" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + id="g5650-2-0-4-3-8-9" + transform="matrix(0,-1,-1,0,347.00351,567.35686)"> + <path + inkscape:transform-center-x="-3.1059024" + sodipodi:type="star" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="path5576-12-1-7-58-6-1-4" + sodipodi:sides="3" + sodipodi:cx="-222.73865" + sodipodi:cy="415.25897" + sodipodi:r1="14.849242" + sodipodi:r2="7.4246211" + sodipodi:arg1="1.5707963" + sodipodi:arg2="2.6179939" + inkscape:flatsided="true" + inkscape:rounded="0" + inkscape:randomized="0" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:transform-center-y="6.2755376" + transform="matrix(0.10770811,0.57792634,-0.57792634,0.10770811,224.52461,390.64831)" /> + </g> + <path + transform="translate(0,-1.5472441e-4)" + inkscape:connector-curvature="0" + id="path6438" + d="M 72.831997,543.06854 C 17.500892,616.78442 35.178561,698.8088 35.178561,698.8088" + style="fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1;stroke-miterlimit:4;stroke-dasharray:none" /> + </g> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="536.26642" + y="972.02087" + id="text5371-2-8-9-1-5" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-3-4-1-4" + x="536.26642" + y="972.02087">true</tspan></text> + <g + transform="matrix(0,-1,-1,0,347.71062,566.6496)" + id="g5650-2-0-4-3-8-9-2-8" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"> + <path + style="fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" + d="m 146.3711,152.21525 c 0,0 -65.760927,60.81119 -8.48528,132.93608" + id="path20172-9-8-9-3-7-4" + inkscape:connector-curvature="0" + transform="matrix(0,1,-1,0,248.85545,276.69312)" /> + <path + transform="matrix(0.38224114,0.44664484,-0.44664484,0.38224114,233.48523,355.54168)" + inkscape:transform-center-y="-1.0388082" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1-7-58-6-1-5-3" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" + inkscape:transform-center-x="4.5299474" /> + </g> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="322.92551" + y="375.54388" + id="text5371-4-6-1" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-9-0-8" + x="322.92551" + y="375.54388">false</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="66.001251" + y="574.40112" + id="text5371-2-8-9-0-3" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/ninenines/cowboy/guide/rest_options.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-3-4-55-3" + x="66.001251" + y="574.40112">true</tspan></text> + </g> +</svg> diff --git a/docs/en/cowboy/2.0/guide/rest_start.png b/docs/en/cowboy/2.0/guide/rest_start.png Binary files differnew file mode 100644 index 00000000..1f1e312e --- /dev/null +++ b/docs/en/cowboy/2.0/guide/rest_start.png diff --git a/docs/en/cowboy/2.0/guide/rest_start.svg b/docs/en/cowboy/2.0/guide/rest_start.svg new file mode 100644 index 00000000..076c6195 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/rest_start.svg @@ -0,0 +1,1356 @@ +<?xml version="1.0" encoding="UTF-8" standalone="no"?> +<!-- Created with Inkscape (http://www.inkscape.org/) --> + +<svg + xmlns:osb="http://www.openswatchbook.org/uri/2009/osb" + xmlns:dc="http://purl.org/dc/elements/1.1/" + xmlns:cc="http://creativecommons.org/ns#" + xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" + xmlns:svg="http://www.w3.org/2000/svg" + xmlns="http://www.w3.org/2000/svg" + xmlns:xlink="http://www.w3.org/1999/xlink" + xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" + xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" + width="744.09448819" + height="1052.3622047" + id="svg2" + version="1.1" + inkscape:version="0.48.4 r9939" + sodipodi:docname="rest_start.svg" + inkscape:export-filename="/home/essen/Dropbox/Public/drawing.png" + inkscape:export-xdpi="90" + inkscape:export-ydpi="90"> + <defs + id="defs4"> + <linearGradient + id="linearGradient5265"> + <stop + style="stop-color:#69d2e7;stop-opacity:1;" + offset="0" + id="stop5267" /> + <stop + style="stop-color:#69d2e7;stop-opacity:0.58823532;" + offset="1" + id="stop5269" /> + </linearGradient> + <linearGradient + id="linearGradient5251"> + <stop + style="stop-color:#69d2e7;stop-opacity:0.78431374;" + offset="0" + id="stop5253" /> + <stop + id="stop5263" + offset="0.5" + style="stop-color:#69d2e7;stop-opacity:1;" /> + <stop + style="stop-color:#69d2e7;stop-opacity:0.39215687;" + offset="1" + id="stop5255" /> + </linearGradient> + <linearGradient + id="linearGradient5233" + osb:paint="solid"> + <stop + style="stop-color:#69d2e7;stop-opacity:1;" + offset="0" + id="stop5235" /> + </linearGradient> + </defs> + <sodipodi:namedview + id="base" + pagecolor="#ffffff" + bordercolor="#666666" + borderopacity="1.0" + inkscape:pageopacity="1" + inkscape:pageshadow="2" + inkscape:zoom="1.0000001" + inkscape:cx="171.11305" + inkscape:cy="549.52821" + inkscape:document-units="px" + inkscape:current-layer="layer1" + showgrid="false" + inkscape:window-width="2560" + inkscape:window-height="1402" + inkscape:window-x="0" + inkscape:window-y="38" + inkscape:window-maximized="1" + inkscape:snap-global="true" + showguides="true"> + <inkscape:grid + type="xygrid" + id="grid5357" + empspacing="5" + visible="true" + enabled="true" + snapvisiblegridlinesonly="true" /> + </sodipodi:namedview> + <metadata + id="metadata7"> + <rdf:RDF> + <cc:Work + rdf:about=""> + <dc:format>image/svg+xml</dc:format> + <dc:type + rdf:resource="http://purl.org/dc/dcmitype/StillImage" /> + <dc:title /> + </cc:Work> + </rdf:RDF> + </metadata> + <g + inkscape:label="Layer 1" + inkscape:groupmode="layer" + id="layer1"> + <path + inkscape:export-ydpi="89.926643" + inkscape:export-xdpi="89.926643" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:connector-curvature="0" + id="use5777" + d="m -360.31658,371.70113 203.00246,0.045" + style="fill:none;stroke:#6d8e41;stroke-width:1;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:1.99999999, 3.99999998;stroke-dashoffset:0" /> + <g + transform="translate(205.92143,-296.03137)" + id="g5650-7"> + <path + inkscape:connector-curvature="0" + id="path5570-9" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-0" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(205.92143,-212.00698)" + id="g5650-9"> + <path + inkscape:connector-curvature="0" + id="path5570-7" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-09" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(205.92143,-129.04326)" + id="g5650-0"> + <path + inkscape:connector-curvature="0" + id="path5570-5" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-1" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(205.92143,-44.866334)" + id="g5650-94"> + <path + inkscape:connector-curvature="0" + id="path5570-71" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-5" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(205.92143,38.329623)" + id="g5650-93"> + <path + inkscape:connector-curvature="0" + id="path5570-3" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-4" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(205.92143,122.59665)" + id="g5650-3"> + <path + inkscape:connector-curvature="0" + id="path5570-93" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-04" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(205.92143,206.62103)" + id="g5650-6"> + <path + inkscape:connector-curvature="0" + id="path5570-78" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-9" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(205.92143,289.59516)" + id="g5650-34"> + <path + inkscape:connector-curvature="0" + id="path5570-30" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-3" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(205.92143,373.37691)" + id="g5650-5"> + <path + inkscape:connector-curvature="0" + id="path5570-90" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-6" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="translate(205.92143,457.4117)" + id="g5650-1"> + <path + inkscape:connector-curvature="0" + id="path5570-33" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-2" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="matrix(0,-1,1,0,-25.673146,80.832304)" + id="g5650-2-0"> + <path + inkscape:connector-curvature="0" + id="path5570-2-5" + d="m -57.78256,275.13761 0,129.13992" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-1" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="matrix(0,-1,1,0,-25.673146,164.49956)" + id="g5650-2-6"> + <path + inkscape:connector-curvature="0" + id="path5570-2-1" + d="m -57.78256,275.13761 0,129.13992" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-6" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="matrix(0,-1,1,0,-25.673146,248.1668)" + id="g5650-2-4"> + <path + inkscape:connector-curvature="0" + id="path5570-2-0" + d="m -57.78256,275.13761 0,129.13992" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-7" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="matrix(0,-1,1,0,-25.673146,331.8341)" + id="g5650-2-04"> + <path + inkscape:connector-curvature="0" + id="path5570-2-9" + d="m -57.78256,275.13761 0,129.13992" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-0" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="matrix(0,-1,1,0,-25.673146,415.50138)" + id="g5650-2-8"> + <path + inkscape:connector-curvature="0" + id="path5570-2-50" + d="m -57.78256,275.13761 0,129.13992" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-2" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="matrix(0,-1,1,0,-25.673146,499.16862)" + id="g5650-2-1"> + <path + inkscape:connector-curvature="0" + id="path5570-2-2" + d="m -57.78256,275.13761 0,129.13992" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-9" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="matrix(0,-1,1,0,-25.673146,582.83589)" + id="g5650-2-3"> + <path + inkscape:connector-curvature="0" + id="path5570-2-10" + d="m -57.78256,275.13761 0,129.13992" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-60" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="matrix(0,-1,1,0,-25.673146,666.50315)" + id="g5650-2-44"> + <path + inkscape:connector-curvature="0" + id="path5570-2-11" + d="m -57.78256,275.13761 0,129.13992" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-73" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <g + transform="matrix(0,-1,1,0,-25.673146,750.17041)" + id="g5650-2-12"> + <path + inkscape:connector-curvature="0" + id="path5570-2-6" + d="m -57.78256,275.13761 0,129.13992" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12-04" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-28" + width="210.17955" + height="35.209244" + x="43.049091" + y="204.67757" + rx="15" /> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-5" + width="210.17955" + height="35.209244" + x="43.049091" + y="288.40311" + rx="15" /> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-8" + width="210.17955" + height="35.209244" + x="43.049091" + y="372.01199" + rx="15" /> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-4" + width="210.17955" + height="35.209244" + x="43.049091" + y="455.67929" + rx="15" /> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-87" + width="210.17955" + height="35.209244" + x="43.049091" + y="539.34656" + rx="15" /> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-41" + width="210.17955" + height="35.209244" + x="43.049091" + y="623.01385" + rx="15" /> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-7" + width="210.17955" + height="35.209244" + x="43.049091" + y="706.68115" + rx="15" /> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-20" + width="210.17955" + height="35.209244" + x="43.049091" + y="790.34839" + rx="15" /> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-3" + width="210.17955" + height="35.209244" + x="43.049091" + y="874.01562" + rx="15" /> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1" + width="210.17955" + height="35.209244" + x="43.049091" + y="121.0042" + rx="15" /> + <g + id="g5650" + transform="translate(0,-0.47597102)"> + <path + inkscape:connector-curvature="0" + id="path5570" + d="m -57.78256,351.41962 0,52.3259" + style="opacity:0.8;fill:none;stroke:#6d8e41;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576" + style="opacity:0.8;fill:#6d8e41;fill-opacity:1;fill-rule:nonzero;stroke:#6d8e41;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273" + width="104.5895" + height="36.392323" + x="-224.02068" + y="29.41218" + rx="15" /> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7" + width="104.5895" + height="36.392323" + x="-224.02068" + y="90.691978" + rx="15" /> + <rect + style="fill:#ffc48c;fill-opacity:1;fill-rule:nonzero;stroke:#d79c64;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-2" + width="104.5895" + height="36.392323" + x="-224.02068" + y="151.97169" + rx="15" /> + <rect + style="fill:#ff9f80;fill-opacity:1;fill-rule:nonzero;stroke:#d77758;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-22" + width="104.5895" + height="36.392323" + x="-224.02068" + y="213.25146" + rx="15" /> + <rect + style="fill:#f56991;fill-opacity:1;fill-rule:nonzero;stroke:#cd4169;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-8" + width="104.5895" + height="36.392323" + x="-224.02068" + y="274.53128" + rx="15" /> + <use + x="0" + y="0" + xlink:href="#rect5273-22" + id="use5355" + transform="translate(319.86479,-176.50006)" + width="744.09448" + height="1052.3622" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="-58.692513" + y="114.39204" + id="text5371" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373" + x="-58.692513" + y="114.39204">some text</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="-58.692513" + y="53.112247" + id="text5371-2" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-6" + x="-58.692513" + y="53.112247">some text</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="148.18575" + y="310.19913" + id="text5371-2-3" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-7" + x="148.18575" + y="310.19913">uri_too_long</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="147.60762" + y="477.47531" + id="text5371-2-3-0" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-7-3" + x="147.60762" + y="477.47531">malformed_request</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="-58.692513" + y="236.95154" + id="text5371-4" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-9" + x="-58.692513" + y="236.95154">some text</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="147.00391" + y="60.912468" + id="text5371-4-0" + sodipodi:linespacing="125%" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + x="147.00391" + y="60.912468" + id="tspan17171">init</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="148.11153" + y="561.14258" + id="text5371-2-9" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-6-8" + x="148.11153" + y="561.14258">is_authorized</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="148.64278" + y="646.58331" + id="text5371-2-7" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-6-2" + x="148.64278" + y="646.58331">forbidden</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="148.29512" + y="728.47717" + id="text5371-2-73" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-6-5" + x="148.29512" + y="728.47717">valid_content_headers</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="147.83809" + y="812.14441" + id="text5371-2-5" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-6-1" + x="147.83809" + y="812.14441">valid_entity_length</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="148.58809" + y="895.81165" + id="text5371-2-1" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-6-71" + x="148.58809" + y="895.81165">...</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="148.13106" + y="142.80627" + id="text5371-2-95" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-6-80" + x="148.13106" + y="142.80627">service_available</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="147.80684" + y="226.4736" + id="text5371-2-32" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-6-27" + x="147.80684" + y="226.4736">known_methods</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="148.05293" + y="393.80801" + id="text5371-2-74" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-6-18" + x="148.05293" + y="393.80801">allowed_methods</tspan></text> + <rect + style="fill:#d1f2a5;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-1-2" + width="210.17955" + height="35.209244" + x="-489.75586" + y="33.4944" + rx="15" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="164.26562" + y="185.95248" + id="text5371-2-391" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-6-63" + x="164.26562" + y="185.95248">true</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="164.26562" + y="269.61978" + id="text5371-2-954" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-6-808" + x="164.26562" + y="269.61978">known*</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="164.26562" + y="353.28702" + id="text5371-2-4" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-6-11" + x="164.26562" + y="353.28702">false</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="164.26562" + y="436.95425" + id="text5371-2-92" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-6-4" + x="164.26562" + y="436.95425">allowed*</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="164.26562" + y="520.62152" + id="text5371-2-739" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-6-0" + x="164.26562" + y="520.62152">false</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="164.26562" + y="604.28876" + id="text5371-2-8" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-6-3" + x="164.26562" + y="604.28876">true</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="164.26562" + y="687.95599" + id="text5371-2-0" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-6-01" + x="164.26562" + y="687.95599">false</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="164.26562" + y="771.62329" + id="text5371-2-2" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-6-33" + x="164.26562" + y="771.62329">true</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:start;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:start;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="164.26562" + y="855.29053" + id="text5371-2-21" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-6-9" + x="164.26562" + y="855.29053">true</tspan></text> + <g + transform="matrix(0,-1,1,0,-513.31414,353.05561)" + id="g5650-2"> + <path + inkscape:connector-curvature="0" + id="path5570-2" + d="m -57.78256,275.13761 0,129.13992" + style="opacity:0.8;fill:none;stroke:#9b3b1c;stroke-width:2;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" /> + <path + transform="matrix(0.58787746,0,0,0.58787746,73.160466,163.35774)" + inkscape:transform-center-y="2.1823437" + d="m -222.73865,430.10821 -12.85982,-22.27386 25.71964,0 z" + inkscape:randomized="0" + inkscape:rounded="0" + inkscape:flatsided="true" + sodipodi:arg2="2.6179939" + sodipodi:arg1="1.5707963" + sodipodi:r2="7.4246211" + sodipodi:r1="14.849242" + sodipodi:cy="415.25897" + sodipodi:cx="-222.73865" + sodipodi:sides="3" + id="path5576-12" + style="opacity:0.8;fill:#9b3b1c;fill-opacity:1;fill-rule:nonzero;stroke:#9b3b1c;stroke-width:0;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + sodipodi:type="star" /> + </g> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="315.26172" + y="123.86062" + id="text5371-4-6" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-9-0" + x="315.26172" + y="123.86062">false</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="315.26172" + y="207.30568" + id="text5371-4-7" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-9-6" + x="315.26172" + y="207.30568">unknown*</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="315.26172" + y="290.75076" + id="text5371-4-2" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-9-01" + x="315.26172" + y="290.75076">true</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="315.26172" + y="374.19577" + id="text5371-4-3" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-9-62" + x="315.26172" + y="374.19577">unallowed*</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="315.26172" + y="457.64084" + id="text5371-4-4" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-9-2" + x="315.26172" + y="457.64084">true</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="315.26172" + y="541.08588" + id="text5371-4-5" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-9-09" + x="315.26172" + y="541.08588">false*</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="315.26172" + y="624.53094" + id="text5371-4-61" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-9-69" + x="315.26172" + y="624.53094">true</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="315.26172" + y="707.97595" + id="text5371-4-58" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-9-5" + x="315.26172" + y="707.97595">false</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#9b3b1c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="315.26172" + y="791.42102" + id="text5371-4-54" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-9-012" + x="315.26172" + y="791.42102">false</tspan></text> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3" + width="264.92532" + height="34.728001" + x="392.03732" + y="121.24477" + rx="15" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="524.53516" + y="143.02283" + id="text5371-6" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + x="524.53516" + y="143.02283" + id="tspan18994">503 service unavailable</tspan></text> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-9" + width="264.92532" + height="34.728001" + x="392.03732" + y="204.93674" + rx="15" /> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-6" + width="264.92532" + height="34.728001" + x="392.03732" + y="288.62869" + rx="15" /> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-1" + width="264.92532" + height="34.728001" + x="392.03732" + y="372.32065" + rx="15" /> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-90" + width="264.92532" + height="34.728001" + x="392.03732" + y="456.01254" + rx="15" /> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-2" + width="264.92532" + height="34.728001" + x="392.03732" + y="539.70447" + rx="15" /> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-3" + width="264.92532" + height="34.728001" + x="392.03732" + y="623.39642" + rx="15" /> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-39" + width="264.92532" + height="34.728001" + x="392.03732" + y="707.08838" + rx="15" /> + <rect + style="fill:#effab4;fill-opacity:1;fill-rule:nonzero;stroke:#c7d28c;stroke-width:3;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5273-7-3-5" + width="264.92532" + height="34.728001" + x="392.03732" + y="790.78027" + rx="15" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="524.26172" + y="227.80464" + id="text5371-7" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-69" + x="524.26172" + y="227.80464">501 not implemented</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="524.26172" + y="311.49661" + id="text5371-9" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-5" + x="524.26172" + y="311.49661">414 request URI too long</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="524.26172" + y="395.18857" + id="text5371-43" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-3" + x="524.26172" + y="395.18857">405 method not allowed</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="524.26172" + y="478.88046" + id="text5371-3" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-67" + x="524.26172" + y="478.88046">400 bad request</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="524.26172" + y="562.57239" + id="text5371-1" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-53" + x="524.26172" + y="562.57239">401 unauthorized</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="524.26172" + y="646.26434" + id="text5371-27" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-64" + x="524.26172" + y="646.26434">403 forbidden</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="524.26172" + y="729.9563" + id="text5371-21" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-58" + x="524.26172" + y="729.9563">501 not implemented</tspan></text> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;text-anchor:middle;fill:#77823c;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="524.26172" + y="813.64819" + id="text5371-5" + sodipodi:linespacing="125%"><tspan + sodipodi:role="line" + id="tspan5373-60" + x="524.26172" + y="813.64819">413 request entity too large</tspan></text> + <rect + style="fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:#a9ca7d;stroke-width:2.44279909;stroke-linecap:butt;stroke-linejoin:round;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;stroke-dashoffset:0" + id="rect5367" + width="207.05719" + height="171.55719" + x="-373.52859" + y="458.58362" + rx="11.072577" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643" /> + <text + xml:space="preserve" + style="font-size:16px;font-style:normal;font-weight:normal;text-align:center;line-height:125%;letter-spacing:0px;word-spacing:0px;writing-mode:lr-tb;text-anchor:middle;fill:#6d8e41;fill-opacity:1;stroke:none;font-family:Sans;-inkscape-font-specification:Sans" + x="-544.69421" + y="-354.17184" + id="text5371-2-3-0-7" + sodipodi:linespacing="125%" + transform="matrix(0,-1,1,0,0,0)" + inkscape:export-filename="/home/essen/extend/cowboy/guide/http_req_resp.png" + inkscape:export-xdpi="89.926643" + inkscape:export-ydpi="89.926643"><tspan + sodipodi:role="line" + id="tspan5373-6-7-3-9" + x="-544.69421" + y="-354.17184">middlewares</tspan></text> + </g> +</svg> diff --git a/docs/en/cowboy/2.0/guide/routing.asciidoc b/docs/en/cowboy/2.0/guide/routing.asciidoc new file mode 100644 index 00000000..6ac2ebde --- /dev/null +++ b/docs/en/cowboy/2.0/guide/routing.asciidoc @@ -0,0 +1,224 @@ +[[routing]] +== Routing + +Cowboy does nothing by default. + +To make Cowboy useful, you need to map URLs to Erlang modules that will +handle the requests. This is called routing. + +When Cowboy receives a request, it tries to match the requested host and +path to the resources given in the dispatch rules. If it matches, then +the associated Erlang code will be executed. + +Routing rules are given per host. Cowboy will first match on the host, +and then try to find a matching path. + +Routes need to be compiled before they can be used by Cowboy. + +=== Structure + +The general structure for the routes is defined as follow. + +[source,erlang] +Routes = [Host1, Host2, ... HostN]. + +Each host contains matching rules for the host along with optional +constraints, and a list of routes for the path component. + +[source,erlang] +Host1 = {HostMatch, PathsList}. +Host2 = {HostMatch, Constraints, PathsList}. + +The list of routes for the path component is defined similar to the +list of hosts. + +[source,erlang] +PathsList = [Path1, Path2, ... PathN]. + +Finally, each path contains matching rules for the path along with +optional constraints, and gives us the handler module to be used +along with options that will be given to it on initialization. + +[source,erlang] +Path1 = {PathMatch, Handler, Opts}. +Path2 = {PathMatch, Constraints, Handler, Opts}. + +Continue reading to learn more about the match syntax and the optional +constraints. + +=== Match syntax + +The match syntax is used to associate host names and paths with their +respective handlers. + +The match syntax is the same for host and path with a few subtleties. +Indeed, the segments separator is different, and the host is matched +starting from the last segment going to the first. All examples will +feature both host and path match rules and explain the differences +when encountered. + +Excluding special values that we will explain at the end of this section, +the simplest match value is a host or a path. It can be given as either +a `string()` or a `binary()`. + +[source,erlang] +---- +PathMatch1 = "/". +PathMatch2 = "/path/to/resource". + +HostMatch1 = "cowboy.example.org". +---- + +As you can see, all paths defined this way must start with a slash +character. Note that these two paths are identical as far as routing +is concerned. + +[source,erlang] +PathMatch2 = "/path/to/resource". +PathMatch3 = "/path/to/resource/". + +Hosts with and without a trailing dot are equivalent for routing. +Similarly, hosts with and without a leading dot are also equivalent. + +[source,erlang] +HostMatch1 = "cowboy.example.org". +HostMatch2 = "cowboy.example.org.". +HostMatch3 = ".cowboy.example.org". + +It is possible to extract segments of the host and path and to store +the values in the `Req` object for later use. We call these kind of +values bindings. + +The syntax for bindings is very simple. A segment that begins with +the `:` character means that what follows until the end of the segment +is the name of the binding in which the segment value will be stored. + +[source,erlang] +PathMatch = "/hats/:name/prices". +HostMatch = ":subdomain.example.org". + +If these two end up matching when routing, you will end up with two +bindings defined, `subdomain` and `name`, each containing the +segment value where they were defined. For example, the URL +`http://test.example.org/hats/wild_cowboy_legendary/prices` will +result in having the value `test` bound to the name `subdomain` +and the value `wild_cowboy_legendary` bound to the name `name`. +They can later be retrieved using `cowboy_req:binding/{2,3}`. The +binding name must be given as an atom. + +There is a special binding name you can use to mimic the underscore +variable in Erlang. Any match against the `_` binding will succeed +but the data will be discarded. This is especially useful for +matching against many domain names in one go. + +[source,erlang] +HostMatch = "ninenines.:_". + +Similarly, it is possible to have optional segments. Anything +between brackets is optional. + +[source,erlang] +PathMatch = "/hats/[page/:number]". +HostMatch = "[www.]ninenines.eu". + +You can also have imbricated optional segments. + +[source,erlang] +PathMatch = "/hats/[page/[:number]]". + +You can retrieve the rest of the host or path using `[...]`. +In the case of hosts it will match anything before, in the case +of paths anything after the previously matched segments. It is +a special case of optional segments, in that it can have +zero, one or many segments. You can then find the segments using +`cowboy_req:host_info/1` and `cowboy_req:path_info/1` respectively. +They will be represented as a list of segments. + +[source,erlang] +PathMatch = "/hats/[...]". +HostMatch = "[...]ninenines.eu". + +If a binding appears twice in the routing rules, then the match +will succeed only if they share the same value. This copies the +Erlang pattern matching behavior. + +[source,erlang] +PathMatch = "/hats/:name/:name". + +This is also true when an optional segment is present. In this +case the two values must be identical only if the segment is +available. + +[source,erlang] +PathMatch = "/hats/:name/[:name]". + +If a binding is defined in both the host and path, then they must +also share the same value. + +[source,erlang] +PathMatch = "/:user/[...]". +HostMatch = ":user.github.com". + +Finally, there are two special match values that can be used. The +first is the atom `'_'` which will match any host or path. + +[source,erlang] +PathMatch = '_'. +HostMatch = '_'. + +The second is the special host match `"*"` which will match the +wildcard path, generally used alongside the `OPTIONS` method. + +[source,erlang] +HostMatch = "*". + +=== Constraints + +After the matching has completed, the resulting bindings can be tested +against a set of constraints. Constraints are only tested when the +binding is defined. They run in the order you defined them. The match +will succeed only if they all succeed. If the match fails, then Cowboy +tries the next route in the list. + +The format used for constraints is the same as match functions in +`cowboy_req`: they are provided as a list of fields which may have +one or more constraints. While the router accepts the same format, +it will skip fields with no constraints and will also ignore default +values, if any. + +Read more about xref:constraints[constraints]. + +=== Compilation + +The structure defined in this chapter needs to be compiled before it is +passed to Cowboy. This allows Cowboy to efficiently lookup the correct +handler to run instead of having to parse the routes repeatedly. + +This can be done with a simple call to `cowboy_router:compile/1`. + +[source,erlang] +---- +Dispatch = cowboy_router:compile([ + %% {HostMatch, list({PathMatch, Handler, Opts})} + {'_', [{'_', my_handler, []}]} +]), +%% Name, NbAcceptors, TransOpts, ProtoOpts +cowboy:start_http(my_http_listener, 100, + [{port, 8080}], + [{env, [{dispatch, Dispatch}]}] +). +---- + +Note that this function will return `{error, badarg}` if the structure +given is incorrect. + +=== Live update + +You can use the `cowboy:set_env/3` function for updating the dispatch +list used by routing. This will apply to all new connections accepted +by the listener. + +[source,erlang] +cowboy:set_env(my_http_listener, dispatch, cowboy_router:compile(Dispatch)). + +Note that you need to compile the routes before updating. diff --git a/docs/en/cowboy/2.0/guide/routing/index.html b/docs/en/cowboy/2.0/guide/routing/index.html new file mode 100644 index 00000000..032d8214 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/routing/index.html @@ -0,0 +1,397 @@ +<!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"> + + <meta name="generator" content="Hugo 0.15" /> + + <title>Nine Nines: Routing</title> + + <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'> + + <link href="/css/bootstrap.min.css" rel="stylesheet"> + <link href="/css/99s.css" 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="Keep in touch!" href="http://twitter.com/lhoguin"><img src="/img/ico_microblog.png" data-hover="/img/ico_microblog_alt.png"></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>Routing</span></h1> + +<div class="paragraph"><p>Cowboy does nothing by default.</p></div>
+<div class="paragraph"><p>To make Cowboy useful, you need to map URLs to Erlang modules that will
+handle the requests. This is called routing.</p></div>
+<div class="paragraph"><p>When Cowboy receives a request, it tries to match the requested host and
+path to the resources given in the dispatch rules. If it matches, then
+the associated Erlang code will be executed.</p></div>
+<div class="paragraph"><p>Routing rules are given per host. Cowboy will first match on the host,
+and then try to find a matching path.</p></div>
+<div class="paragraph"><p>Routes need to be compiled before they can be used by Cowboy.</p></div>
+<div class="sect1">
+<h2 id="_structure">Structure</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>The general structure for the routes is defined as follow.</p></div>
+<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="color: #009900">Routes</span> <span style="color: #990000">=</span> [<span style="color: #009900">Host1</span>, <span style="color: #009900">Host2</span>, <span style="color: #990000">...</span> <span style="color: #009900">HostN</span>]<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Each host contains matching rules for the host along with optional
+constraints, and a list of routes for the path component.</p></div>
+<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="color: #009900">Host1</span> <span style="color: #990000">=</span> {<span style="color: #009900">HostMatch</span>, <span style="color: #009900">PathsList</span>}<span style="color: #990000">.</span>
+<span style="color: #009900">Host2</span> <span style="color: #990000">=</span> {<span style="color: #009900">HostMatch</span>, <span style="color: #009900">Constraints</span>, <span style="color: #009900">PathsList</span>}<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>The list of routes for the path component is defined similar to the
+list of hosts.</p></div>
+<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="color: #009900">PathsList</span> <span style="color: #990000">=</span> [<span style="color: #009900">Path1</span>, <span style="color: #009900">Path2</span>, <span style="color: #990000">...</span> <span style="color: #009900">PathN</span>]<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Finally, each path contains matching rules for the path along with
+optional constraints, and gives us the handler module to be used
+along with options that will be given to it on initialization.</p></div>
+<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="color: #009900">Path1</span> <span style="color: #990000">=</span> {<span style="color: #009900">PathMatch</span>, <span style="color: #009900">Handler</span>, <span style="color: #009900">Opts</span>}<span style="color: #990000">.</span>
+<span style="color: #009900">Path2</span> <span style="color: #990000">=</span> {<span style="color: #009900">PathMatch</span>, <span style="color: #009900">Constraints</span>, <span style="color: #009900">Handler</span>, <span style="color: #009900">Opts</span>}<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Continue reading to learn more about the match syntax and the optional
+constraints.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_match_syntax">Match syntax</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>The match syntax is used to associate host names and paths with their
+respective handlers.</p></div>
+<div class="paragraph"><p>The match syntax is the same for host and path with a few subtleties.
+Indeed, the segments separator is different, and the host is matched
+starting from the last segment going to the first. All examples will
+feature both host and path match rules and explain the differences
+when encountered.</p></div>
+<div class="paragraph"><p>Excluding special values that we will explain at the end of this section,
+the simplest match value is a host or a path. It can be given as either
+a <code>string()</code> or a <code>binary()</code>.</p></div>
+<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="color: #009900">PathMatch1</span> <span style="color: #990000">=</span> <span style="color: #FF0000">"/"</span><span style="color: #990000">.</span>
+<span style="color: #009900">PathMatch2</span> <span style="color: #990000">=</span> <span style="color: #FF0000">"/path/to/resource"</span><span style="color: #990000">.</span>
+
+<span style="color: #009900">HostMatch1</span> <span style="color: #990000">=</span> <span style="color: #FF0000">"cowboy.example.org"</span><span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>As you can see, all paths defined this way must start with a slash
+character. Note that these two paths are identical as far as routing
+is concerned.</p></div>
+<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="color: #009900">PathMatch2</span> <span style="color: #990000">=</span> <span style="color: #FF0000">"/path/to/resource"</span><span style="color: #990000">.</span>
+<span style="color: #009900">PathMatch3</span> <span style="color: #990000">=</span> <span style="color: #FF0000">"/path/to/resource/"</span><span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Hosts with and without a trailing dot are equivalent for routing.
+Similarly, hosts with and without a leading dot are also equivalent.</p></div>
+<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="color: #009900">HostMatch1</span> <span style="color: #990000">=</span> <span style="color: #FF0000">"cowboy.example.org"</span><span style="color: #990000">.</span>
+<span style="color: #009900">HostMatch2</span> <span style="color: #990000">=</span> <span style="color: #FF0000">"cowboy.example.org."</span><span style="color: #990000">.</span>
+<span style="color: #009900">HostMatch3</span> <span style="color: #990000">=</span> <span style="color: #FF0000">".cowboy.example.org"</span><span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>It is possible to extract segments of the host and path and to store
+the values in the <code>Req</code> object for later use. We call these kind of
+values bindings.</p></div>
+<div class="paragraph"><p>The syntax for bindings is very simple. A segment that begins with
+the <code>:</code> character means that what follows until the end of the segment
+is the name of the binding in which the segment value will be stored.</p></div>
+<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="color: #009900">PathMatch</span> <span style="color: #990000">=</span> <span style="color: #FF0000">"/hats/:name/prices"</span><span style="color: #990000">.</span>
+<span style="color: #009900">HostMatch</span> <span style="color: #990000">=</span> <span style="color: #FF0000">":subdomain.example.org"</span><span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>If these two end up matching when routing, you will end up with two
+bindings defined, <code>subdomain</code> and <code>name</code>, each containing the
+segment value where they were defined. For example, the URL
+<code>http://test.example.org/hats/wild_cowboy_legendary/prices</code> will
+result in having the value <code>test</code> bound to the name <code>subdomain</code>
+and the value <code>wild_cowboy_legendary</code> bound to the name <code>name</code>.
+They can later be retrieved using <code>cowboy_req:binding/{2,3}</code>. The
+binding name must be given as an atom.</p></div>
+<div class="paragraph"><p>There is a special binding name you can use to mimic the underscore
+variable in Erlang. Any match against the <code>_</code> binding will succeed
+but the data will be discarded. This is especially useful for
+matching against many domain names in one go.</p></div>
+<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="color: #009900">HostMatch</span> <span style="color: #990000">=</span> <span style="color: #FF0000">"ninenines.:_"</span><span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Similarly, it is possible to have optional segments. Anything
+between brackets is optional.</p></div>
+<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="color: #009900">PathMatch</span> <span style="color: #990000">=</span> <span style="color: #FF0000">"/hats/[page/:number]"</span><span style="color: #990000">.</span>
+<span style="color: #009900">HostMatch</span> <span style="color: #990000">=</span> <span style="color: #FF0000">"[www.]ninenines.eu"</span><span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>You can also have imbricated optional segments.</p></div>
+<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="color: #009900">PathMatch</span> <span style="color: #990000">=</span> <span style="color: #FF0000">"/hats/[page/[:number]]"</span><span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>You can retrieve the rest of the host or path using <code>[...]</code>.
+In the case of hosts it will match anything before, in the case
+of paths anything after the previously matched segments. It is
+a special case of optional segments, in that it can have
+zero, one or many segments. You can then find the segments using
+<code>cowboy_req:host_info/1</code> and <code>cowboy_req:path_info/1</code> respectively.
+They will be represented as a list of segments.</p></div>
+<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="color: #009900">PathMatch</span> <span style="color: #990000">=</span> <span style="color: #FF0000">"/hats/[...]"</span><span style="color: #990000">.</span>
+<span style="color: #009900">HostMatch</span> <span style="color: #990000">=</span> <span style="color: #FF0000">"[...]ninenines.eu"</span><span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>If a binding appears twice in the routing rules, then the match
+will succeed only if they share the same value. This copies the
+Erlang pattern matching behavior.</p></div>
+<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="color: #009900">PathMatch</span> <span style="color: #990000">=</span> <span style="color: #FF0000">"/hats/:name/:name"</span><span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>This is also true when an optional segment is present. In this
+case the two values must be identical only if the segment is
+available.</p></div>
+<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="color: #009900">PathMatch</span> <span style="color: #990000">=</span> <span style="color: #FF0000">"/hats/:name/[:name]"</span><span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>If a binding is defined in both the host and path, then they must
+also share the same value.</p></div>
+<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="color: #009900">PathMatch</span> <span style="color: #990000">=</span> <span style="color: #FF0000">"/:user/[...]"</span><span style="color: #990000">.</span>
+<span style="color: #009900">HostMatch</span> <span style="color: #990000">=</span> <span style="color: #FF0000">":user.github.com"</span><span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Finally, there are two special match values that can be used. The
+first is the atom <code>'_'</code> which will match any host or path.</p></div>
+<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="color: #009900">PathMatch</span> <span style="color: #990000">=</span> <span style="color: #FF6600">'_'</span><span style="color: #990000">.</span>
+<span style="color: #009900">HostMatch</span> <span style="color: #990000">=</span> <span style="color: #FF6600">'_'</span><span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>The second is the special host match <code>"*"</code> which will match the
+wildcard path, generally used alongside the <code>OPTIONS</code> method.</p></div>
+<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="color: #009900">HostMatch</span> <span style="color: #990000">=</span> <span style="color: #FF0000">"*"</span><span style="color: #990000">.</span></tt></pre></div></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_constraints">Constraints</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>After the matching has completed, the resulting bindings can be tested
+against a set of constraints. Constraints are only tested when the
+binding is defined. They run in the order you defined them. The match
+will succeed only if they all succeed. If the match fails, then Cowboy
+tries the next route in the list.</p></div>
+<div class="paragraph"><p>The format used for constraints is the same as match functions in
+<code>cowboy_req</code>: they are provided as a list of fields which may have
+one or more constraints. While the router accepts the same format,
+it will skip fields with no constraints and will also ignore default
+values, if any.</p></div>
+<div class="paragraph"><p>Read more about <a href="../constraints">constraints</a>.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_compilation">Compilation</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>The structure defined in this chapter needs to be compiled before it is
+passed to Cowboy. This allows Cowboy to efficiently lookup the correct
+handler to run instead of having to parse the routes repeatedly.</p></div>
+<div class="paragraph"><p>This can be done with a simple call to <code>cowboy_router:compile/1</code>.</p></div>
+<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="color: #009900">Dispatch</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_router:compile</span></span>([
+ <span style="font-style: italic"><span style="color: #9A1900">%% {HostMatch, list({PathMatch, Handler, Opts})}</span></span>
+ {<span style="color: #FF6600">'_'</span>, [{<span style="color: #FF6600">'_'</span>, <span style="color: #FF6600">my_handler</span>, []}]}
+]),
+<span style="font-style: italic"><span style="color: #9A1900">%% Name, NbAcceptors, TransOpts, ProtoOpts</span></span>
+<span style="font-weight: bold"><span style="color: #000000">cowboy:start_http</span></span>(<span style="color: #FF6600">my_http_listener</span>, <span style="color: #993399">100</span>,
+ [{<span style="color: #FF6600">port</span>, <span style="color: #993399">8080</span>}],
+ [{<span style="color: #FF6600">env</span>, [{<span style="color: #FF6600">dispatch</span>, <span style="color: #009900">Dispatch</span>}]}]
+)<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Note that this function will return <code>{error, badarg}</code> if the structure
+given is incorrect.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_live_update">Live update</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>You can use the <code>cowboy:set_env/3</code> function for updating the dispatch
+list used by routing. This will apply to all new connections accepted
+by the listener.</p></div>
+<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">cowboy:set_env</span></span>(<span style="color: #FF6600">my_http_listener</span>, <span style="color: #FF6600">dispatch</span>, <span style="font-weight: bold"><span style="color: #000000">cowboy_router:compile</span></span>(<span style="color: #009900">Dispatch</span>))<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Note that you need to compile the routes before updating.</p></div>
+</div>
+</div>
+ + + +</div> + +<div class="span3 sidecol"> + + +<h3> + Cowboy + 2.0 + + User Guide +</h3> + +<ul> + + <li><a href="/docs/en/cowboy/2.0/guide">User Guide</a></li> + + + <li><a href="/docs/en/cowboy/2.0/manual">Function Reference</a></li> + + +</ul> + +<h4 id="docs-nav">Navigation</h4> + +<h4>Version select</h4> +<ul> + + + + <li><a href="/docs/en/cowboy/1.0/guide">1.0</a></li> + + <li><a href="/docs/en/cowboy/2.0/guide">2.0</a></li> + +</ul> + +</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 © Loïc Hoguin 2012-2016</p> + </div> + </div> + </div> + </footer> + + + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> + <script src="/js/bootstrap-carousel.js"></script> + <script src="/js/bootstrap-dropdown.js"></script> + <script src="/js/custom.js"></script> + </body> +</html> + + diff --git a/docs/en/cowboy/2.0/guide/static_files.asciidoc b/docs/en/cowboy/2.0/guide/static_files.asciidoc new file mode 100644 index 00000000..39197a88 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/static_files.asciidoc @@ -0,0 +1,171 @@ +[[static_files]] +== Static files + +Cowboy comes with a special handler built as a REST handler +and designed specifically for serving static files. It is +provided as a convenience and provides a quick solution for +serving files during development. + +For systems in production, consider using one of the many +Content Distribution Network (CDN) available on the market, +as they are the best solution for serving files. They are +covered in the next chapter. If you decide against using a +CDN solution, then please look at the chapter after that, +as it explains how to efficiently serve static files on +your own. + +The static handler can serve either one file or all files +from a given directory. It can also send etag headers for +client-side caching. + +To use the static file handler, simply add routes for it +with the appropriate options. + +=== Serve one file + +You can use the static handler to serve one specific file +from an application's private directory. This is particularly +useful to serve an 'index.html' file when the client requests +the `/` path, for example. The path configured is relative +to the given application's private directory. + +The following rule will serve the file 'static/index.html' +from the application `my_app`'s priv directory whenever the +path `/` is accessed. + +[source,erlang] +{"/", cowboy_static, {priv_file, my_app, "static/index.html"}} + +You can also specify the absolute path to a file, or the +path to the file relative to the current directory. + +[source,erlang] +{"/", cowboy_static, {file, "/var/www/index.html"}} + +=== Serve all files from a directory + +You can also use the static handler to serve all files that +can be found in the configured directory. The handler will +use the `path_info` information to resolve the file location, +which means that your route must end with a `[...]` pattern +for it to work. All files are served, including the ones that +may be found in subfolders. + +You can specify the directory relative to an application's +private directory. + +The following rule will serve any file found in the application +`my_app`'s priv directory inside the `static/assets` folder +whenever the requested path begins with `/assets/`. + +[source,erlang] +{"/assets/[...]", cowboy_static, {priv_dir, my_app, "static/assets"}} + +You can also specify the absolute path to the directory or +set it relative to the current directory. + +[source,erlang] +{"/assets/[...]", cowboy_static, {dir, "/var/www/assets"}} + +=== Customize the mimetype detection + +By default, Cowboy will attempt to recognize the mimetype +of your static files by looking at the extension. + +You can override the function that figures out the mimetype +of the static files. It can be useful when Cowboy is missing +a mimetype you need to handle, or when you want to reduce +the list to make lookups faster. You can also give a +hard-coded mimetype that will be used unconditionally. + +Cowboy comes with two functions built-in. The default +function only handles common file types used when building +Web applications. The other function is an extensive list +of hundreds of mimetypes that should cover almost any need +you may have. You can of course create your own function. + +To use the default function, you should not have to configure +anything, as it is the default. If you insist, though, the +following will do the job. + +[source,erlang] +---- +{"/assets/[...]", cowboy_static, {priv_dir, my_app, "static/assets", + [{mimetypes, cow_mimetypes, web}]}} +---- + +As you can see, there is an optional field that may contain +a list of less used options, like mimetypes or etag. All option +types have this optional field. + +To use the function that will detect almost any mimetype, +the following configuration will do. + +[source,erlang] +---- +{"/assets/[...]", cowboy_static, {priv_dir, my_app, "static/assets", + [{mimetypes, cow_mimetypes, all}]}} +---- + +You probably noticed the pattern by now. The configuration +expects a module and a function name, so you can use any +of your own functions instead. + +[source,erlang] +---- +{"/assets/[...]", cowboy_static, {priv_dir, my_app, "static/assets", + [{mimetypes, Module, Function}]}} +---- + +The function that performs the mimetype detection receives +a single argument that is the path to the file on disk. It +is recommended to return the mimetype in tuple form, although +a binary string is also allowed (but will require extra +processing). If the function can't figure out the mimetype, +then it should return `{<<"application">>, <<"octet-stream">>, []}`. + +When the static handler fails to find the extension in the +list, it will send the file as `application/octet-stream`. +A browser receiving such file will attempt to download it +directly to disk. + +Finally, the mimetype can be hard-coded for all files. +This is especially useful in combination with the `file` +and `priv_file` options as it avoids needless computation. + +[source,erlang] +---- +{"/", cowboy_static, {priv_file, my_app, "static/index.html", + [{mimetypes, {<<"text">>, <<"html">>, []}}]}} +---- + +=== Generate an etag + +By default, the static handler will generate an etag header +value based on the size and modified time. This solution +can not be applied to all systems though. It would perform +rather poorly over a cluster of nodes, for example, as the +file metadata will vary from server to server, giving a +different etag on each server. + +You can however change the way the etag is calculated. + +[source,erlang] +---- +{"/assets/[...]", cowboy_static, {priv_dir, my_app, "static/assets", + [{etag, Module, Function}]}} +---- + +This function will receive three arguments: the path to the +file on disk, the size of the file and the last modification +time. In a distributed setup, you would typically use the +file path to retrieve an etag value that is identical across +all your servers. + +You can also completely disable etag handling. + +[source,erlang] +---- +{"/assets/[...]", cowboy_static, {priv_dir, my_app, "static/assets", + [{etag, false}]}} +---- diff --git a/docs/en/cowboy/2.0/guide/static_files/index.html b/docs/en/cowboy/2.0/guide/static_files/index.html new file mode 100644 index 00000000..6ef9d782 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/static_files/index.html @@ -0,0 +1,316 @@ +<!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"> + + <meta name="generator" content="Hugo 0.15" /> + + <title>Nine Nines: Static files</title> + + <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'> + + <link href="/css/bootstrap.min.css" rel="stylesheet"> + <link href="/css/99s.css" 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="Keep in touch!" href="http://twitter.com/lhoguin"><img src="/img/ico_microblog.png" data-hover="/img/ico_microblog_alt.png"></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>Static files</span></h1> + +<div class="paragraph"><p>Cowboy comes with a special handler built as a REST handler
+and designed specifically for serving static files. It is
+provided as a convenience and provides a quick solution for
+serving files during development.</p></div>
+<div class="paragraph"><p>For systems in production, consider using one of the many
+Content Distribution Network (CDN) available on the market,
+as they are the best solution for serving files. They are
+covered in the next chapter. If you decide against using a
+CDN solution, then please look at the chapter after that,
+as it explains how to efficiently serve static files on
+your own.</p></div>
+<div class="paragraph"><p>The static handler can serve either one file or all files
+from a given directory. It can also send etag headers for
+client-side caching.</p></div>
+<div class="paragraph"><p>To use the static file handler, simply add routes for it
+with the appropriate options.</p></div>
+<div class="sect1">
+<h2 id="_serve_one_file">Serve one file</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>You can use the static handler to serve one specific file
+from an application’s private directory. This is particularly
+useful to serve an <em>index.html</em> file when the client requests
+the <code>/</code> path, for example. The path configured is relative
+to the given application’s private directory.</p></div>
+<div class="paragraph"><p>The following rule will serve the file <em>static/index.html</em>
+from the application <code>my_app</code>'s priv directory whenever the
+path <code>/</code> is accessed.</p></div>
+<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="color: #FF0000">"/"</span>, <span style="color: #FF6600">cowboy_static</span>, {<span style="color: #FF6600">priv_file</span>, <span style="color: #FF6600">my_app</span>, <span style="color: #FF0000">"static/index.html"</span>}}</tt></pre></div></div>
+<div class="paragraph"><p>You can also specify the absolute path to a file, or the
+path to the file relative to the current directory.</p></div>
+<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="color: #FF0000">"/"</span>, <span style="color: #FF6600">cowboy_static</span>, {<span style="color: #FF6600">file</span>, <span style="color: #FF0000">"/var/www/index.html"</span>}}</tt></pre></div></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_serve_all_files_from_a_directory">Serve all files from a directory</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>You can also use the static handler to serve all files that
+can be found in the configured directory. The handler will
+use the <code>path_info</code> information to resolve the file location,
+which means that your route must end with a <code>[...]</code> pattern
+for it to work. All files are served, including the ones that
+may be found in subfolders.</p></div>
+<div class="paragraph"><p>You can specify the directory relative to an application’s
+private directory.</p></div>
+<div class="paragraph"><p>The following rule will serve any file found in the application
+<code>my_app</code>'s priv directory inside the <code>static/assets</code> folder
+whenever the requested path begins with <code>/assets/</code>.</p></div>
+<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="color: #FF0000">"/assets/[...]"</span>, <span style="color: #FF6600">cowboy_static</span>, {<span style="color: #FF6600">priv_dir</span>, <span style="color: #FF6600">my_app</span>, <span style="color: #FF0000">"static/assets"</span>}}</tt></pre></div></div>
+<div class="paragraph"><p>You can also specify the absolute path to the directory or
+set it relative to the current directory.</p></div>
+<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="color: #FF0000">"/assets/[...]"</span>, <span style="color: #FF6600">cowboy_static</span>, {<span style="color: #FF6600">dir</span>, <span style="color: #FF0000">"/var/www/assets"</span>}}</tt></pre></div></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_customize_the_mimetype_detection">Customize the mimetype detection</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>By default, Cowboy will attempt to recognize the mimetype
+of your static files by looking at the extension.</p></div>
+<div class="paragraph"><p>You can override the function that figures out the mimetype
+of the static files. It can be useful when Cowboy is missing
+a mimetype you need to handle, or when you want to reduce
+the list to make lookups faster. You can also give a
+hard-coded mimetype that will be used unconditionally.</p></div>
+<div class="paragraph"><p>Cowboy comes with two functions built-in. The default
+function only handles common file types used when building
+Web applications. The other function is an extensive list
+of hundreds of mimetypes that should cover almost any need
+you may have. You can of course create your own function.</p></div>
+<div class="paragraph"><p>To use the default function, you should not have to configure
+anything, as it is the default. If you insist, though, the
+following will do the job.</p></div>
+<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="color: #FF0000">"/assets/[...]"</span>, <span style="color: #FF6600">cowboy_static</span>, {<span style="color: #FF6600">priv_dir</span>, <span style="color: #FF6600">my_app</span>, <span style="color: #FF0000">"static/assets"</span>,
+ [{<span style="color: #FF6600">mimetypes</span>, <span style="color: #FF6600">cow_mimetypes</span>, <span style="color: #FF6600">web</span>}]}}</tt></pre></div></div>
+<div class="paragraph"><p>As you can see, there is an optional field that may contain
+a list of less used options, like mimetypes or etag. All option
+types have this optional field.</p></div>
+<div class="paragraph"><p>To use the function that will detect almost any mimetype,
+the following configuration will do.</p></div>
+<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="color: #FF0000">"/assets/[...]"</span>, <span style="color: #FF6600">cowboy_static</span>, {<span style="color: #FF6600">priv_dir</span>, <span style="color: #FF6600">my_app</span>, <span style="color: #FF0000">"static/assets"</span>,
+ [{<span style="color: #FF6600">mimetypes</span>, <span style="color: #FF6600">cow_mimetypes</span>, <span style="color: #FF6600">all</span>}]}}</tt></pre></div></div>
+<div class="paragraph"><p>You probably noticed the pattern by now. The configuration
+expects a module and a function name, so you can use any
+of your own functions instead.</p></div>
+<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="color: #FF0000">"/assets/[...]"</span>, <span style="color: #FF6600">cowboy_static</span>, {<span style="color: #FF6600">priv_dir</span>, <span style="color: #FF6600">my_app</span>, <span style="color: #FF0000">"static/assets"</span>,
+ [{<span style="color: #FF6600">mimetypes</span>, <span style="color: #009900">Module</span>, <span style="color: #009900">Function</span>}]}}</tt></pre></div></div>
+<div class="paragraph"><p>The function that performs the mimetype detection receives
+a single argument that is the path to the file on disk. It
+is recommended to return the mimetype in tuple form, although
+a binary string is also allowed (but will require extra
+processing). If the function can’t figure out the mimetype,
+then it should return <code>{<<"application">>, <<"octet-stream">>, []}</code>.</p></div>
+<div class="paragraph"><p>When the static handler fails to find the extension in the
+list, it will send the file as <code>application/octet-stream</code>.
+A browser receiving such file will attempt to download it
+directly to disk.</p></div>
+<div class="paragraph"><p>Finally, the mimetype can be hard-coded for all files.
+This is especially useful in combination with the <code>file</code>
+and <code>priv_file</code> options as it avoids needless computation.</p></div>
+<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="color: #FF0000">"/"</span>, <span style="color: #FF6600">cowboy_static</span>, {<span style="color: #FF6600">priv_file</span>, <span style="color: #FF6600">my_app</span>, <span style="color: #FF0000">"static/index.html"</span>,
+ [{<span style="color: #FF6600">mimetypes</span>, {<span style="color: #990000"><<</span><span style="color: #FF0000">"text"</span><span style="color: #990000">>></span>, <span style="color: #990000"><<</span><span style="color: #FF0000">"html"</span><span style="color: #990000">>></span>, []}}]}}</tt></pre></div></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_generate_an_etag">Generate an etag</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>By default, the static handler will generate an etag header
+value based on the size and modified time. This solution
+can not be applied to all systems though. It would perform
+rather poorly over a cluster of nodes, for example, as the
+file metadata will vary from server to server, giving a
+different etag on each server.</p></div>
+<div class="paragraph"><p>You can however change the way the etag is calculated.</p></div>
+<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="color: #FF0000">"/assets/[...]"</span>, <span style="color: #FF6600">cowboy_static</span>, {<span style="color: #FF6600">priv_dir</span>, <span style="color: #FF6600">my_app</span>, <span style="color: #FF0000">"static/assets"</span>,
+ [{<span style="color: #FF6600">etag</span>, <span style="color: #009900">Module</span>, <span style="color: #009900">Function</span>}]}}</tt></pre></div></div>
+<div class="paragraph"><p>This function will receive three arguments: the path to the
+file on disk, the size of the file and the last modification
+time. In a distributed setup, you would typically use the
+file path to retrieve an etag value that is identical across
+all your servers.</p></div>
+<div class="paragraph"><p>You can also completely disable etag handling.</p></div>
+<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="color: #FF0000">"/assets/[...]"</span>, <span style="color: #FF6600">cowboy_static</span>, {<span style="color: #FF6600">priv_dir</span>, <span style="color: #FF6600">my_app</span>, <span style="color: #FF0000">"static/assets"</span>,
+ [{<span style="color: #FF6600">etag</span>, <span style="color: #000080">false</span>}]}}</tt></pre></div></div>
+</div>
+</div>
+ + + +</div> + +<div class="span3 sidecol"> + + +<h3> + Cowboy + 2.0 + + User Guide +</h3> + +<ul> + + <li><a href="/docs/en/cowboy/2.0/guide">User Guide</a></li> + + + <li><a href="/docs/en/cowboy/2.0/manual">Function Reference</a></li> + + +</ul> + +<h4 id="docs-nav">Navigation</h4> + +<h4>Version select</h4> +<ul> + + + + <li><a href="/docs/en/cowboy/1.0/guide">1.0</a></li> + + <li><a href="/docs/en/cowboy/2.0/guide">2.0</a></li> + +</ul> + +</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 © Loïc Hoguin 2012-2016</p> + </div> + </div> + </div> + </footer> + + + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> + <script src="/js/bootstrap-carousel.js"></script> + <script src="/js/bootstrap-dropdown.js"></script> + <script src="/js/custom.js"></script> + </body> +</html> + + diff --git a/docs/en/cowboy/2.0/guide/sub_protocols.asciidoc b/docs/en/cowboy/2.0/guide/sub_protocols.asciidoc new file mode 100644 index 00000000..63fd52be --- /dev/null +++ b/docs/en/cowboy/2.0/guide/sub_protocols.asciidoc @@ -0,0 +1,68 @@ +[[sub_protocols]] +== Sub protocols + +Sub protocols are used for creating new types of handlers that +provide extra functionality in a reusable way. Cowboy uses this +mechanism to provide its loop, REST and Websocket handlers. + +This chapter will explain how to create your own sub protocols +and handler types. + +=== Usage + +To switch to a sub protocol, the `init/2` callback must return +the name of the sub protocol module. Everything past this point +is handled by the sub protocol. + +[source,erlang] +---- +init(Req, _Opts) -> + {cowboy_websocket, Req, #state{}}. +---- + +The return value may also have a `Timeout` value and/or the +atom `hibernate`. These options are useful for long living +connections. When they are not provided, the timeout value +defaults to `infinity` and the hibernate value to `run`. + +The following snippet switches to the `my_protocol` sub +protocol, sets the timeout value to 5 seconds and enables +hibernation: + +[source,erlang] +---- +init(Req, _Opts) -> + {my_protocol, Req, #state{}, 5000, hibernate}. +---- + +If a sub protocol does not make use of these options, it should +crash if it receives anything other than the default values. + +=== Upgrade + +After the `init/2` function returns, Cowboy will then call the +`upgrade/6` function. This is the only callback defined by the +`cowboy_sub_protocol` behavior. + +The function is named `upgrade` because it mimics the mechanism +of HTTP protocol upgrades. For some sub protocols, like Websocket, +an actual upgrade is performed. For others, like REST, this is +only an upgrade at Cowboy's level and the client has nothing to +do about it. + +The upgrade callback receives the Req object, the middleware +environment, the handler and its options, and the aforementioned +timeout and hibernate values. + +[source,erlang] +---- +upgrade(Req, Env, Handler, HandlerOpts, Timeout, Hibernate) -> + %% Sub protocol code here. +---- + +This callback is expected to behave like a middleware and to +return an updated environment and Req object. + +Sub protocols are expected to call the `cowboy_handler:terminate/4` +function when they terminate. This function will make sure that +the optional `terminate/3` callback is called, if present. diff --git a/docs/en/cowboy/2.0/guide/sub_protocols/index.html b/docs/en/cowboy/2.0/guide/sub_protocols/index.html new file mode 100644 index 00000000..c75da6a4 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/sub_protocols/index.html @@ -0,0 +1,206 @@ +<!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"> + + <meta name="generator" content="Hugo 0.15" /> + + <title>Nine Nines: Sub protocols</title> + + <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'> + + <link href="/css/bootstrap.min.css" rel="stylesheet"> + <link href="/css/99s.css" 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="Keep in touch!" href="http://twitter.com/lhoguin"><img src="/img/ico_microblog.png" data-hover="/img/ico_microblog_alt.png"></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>Sub protocols</span></h1> + +<div class="paragraph"><p>Sub protocols are used for creating new types of handlers that
+provide extra functionality in a reusable way. Cowboy uses this
+mechanism to provide its loop, REST and Websocket handlers.</p></div>
+<div class="paragraph"><p>This chapter will explain how to create your own sub protocols
+and handler types.</p></div>
+<div class="sect1">
+<h2 id="_usage">Usage</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>To switch to a sub protocol, the <code>init/2</code> callback must return
+the name of the sub protocol module. Everything past this point
+is handled by the sub protocol.</p></div>
+<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">init</span></span>(<span style="color: #009900">Req</span>, <span style="color: #009900">_Opts</span>) <span style="color: #990000">-></span>
+ {<span style="color: #FF6600">cowboy_websocket</span>, <span style="color: #009900">Req</span>, <span style="color: #008080">#state</span>{}}<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>The return value may also have a <code>Timeout</code> value and/or the
+atom <code>hibernate</code>. These options are useful for long living
+connections. When they are not provided, the timeout value
+defaults to <code>infinity</code> and the hibernate value to <code>run</code>.</p></div>
+<div class="paragraph"><p>The following snippet switches to the <code>my_protocol</code> sub
+protocol, sets the timeout value to 5 seconds and enables
+hibernation:</p></div>
+<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">init</span></span>(<span style="color: #009900">Req</span>, <span style="color: #009900">_Opts</span>) <span style="color: #990000">-></span>
+ {<span style="color: #FF6600">my_protocol</span>, <span style="color: #009900">Req</span>, <span style="color: #008080">#state</span>{}, <span style="color: #993399">5000</span>, <span style="color: #FF6600">hibernate</span>}<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>If a sub protocol does not make use of these options, it should
+crash if it receives anything other than the default values.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_upgrade">Upgrade</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>After the <code>init/2</code> function returns, Cowboy will then call the
+<code>upgrade/6</code> function. This is the only callback defined by the
+<code>cowboy_sub_protocol</code> behavior.</p></div>
+<div class="paragraph"><p>The function is named <code>upgrade</code> because it mimics the mechanism
+of HTTP protocol upgrades. For some sub protocols, like Websocket,
+an actual upgrade is performed. For others, like REST, this is
+only an upgrade at Cowboy’s level and the client has nothing to
+do about it.</p></div>
+<div class="paragraph"><p>The upgrade callback receives the Req object, the middleware
+environment, the handler and its options, and the aforementioned
+timeout and hibernate values.</p></div>
+<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">upgrade</span></span>(<span style="color: #009900">Req</span>, <span style="color: #009900">Env</span>, <span style="color: #009900">Handler</span>, <span style="color: #009900">HandlerOpts</span>, <span style="color: #009900">Timeout</span>, <span style="color: #009900">Hibernate</span>) <span style="color: #990000">-></span>
+ <span style="font-style: italic"><span style="color: #9A1900">%% Sub protocol code here.</span></span></tt></pre></div></div>
+<div class="paragraph"><p>This callback is expected to behave like a middleware and to
+return an updated environment and Req object.</p></div>
+<div class="paragraph"><p>Sub protocols are expected to call the <code>cowboy_handler:terminate/4</code>
+function when they terminate. This function will make sure that
+the optional <code>terminate/3</code> callback is called, if present.</p></div>
+</div>
+</div>
+ + + +</div> + +<div class="span3 sidecol"> + + +<h3> + Cowboy + 2.0 + + User Guide +</h3> + +<ul> + + <li><a href="/docs/en/cowboy/2.0/guide">User Guide</a></li> + + + <li><a href="/docs/en/cowboy/2.0/manual">Function Reference</a></li> + + +</ul> + +<h4 id="docs-nav">Navigation</h4> + +<h4>Version select</h4> +<ul> + + + + <li><a href="/docs/en/cowboy/1.0/guide">1.0</a></li> + + <li><a href="/docs/en/cowboy/2.0/guide">2.0</a></li> + +</ul> + +</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 © Loïc Hoguin 2012-2016</p> + </div> + </div> + </div> + </footer> + + + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> + <script src="/js/bootstrap-carousel.js"></script> + <script src="/js/bootstrap-dropdown.js"></script> + <script src="/js/custom.js"></script> + </body> +</html> + + diff --git a/docs/en/cowboy/2.0/guide/ws_handlers.asciidoc b/docs/en/cowboy/2.0/guide/ws_handlers.asciidoc new file mode 100644 index 00000000..9ddddf4c --- /dev/null +++ b/docs/en/cowboy/2.0/guide/ws_handlers.asciidoc @@ -0,0 +1,196 @@ +[[ws_handlers]] +== Handling Websocket connections + +A special handler is required for handling Websocket connections. +Websocket handlers allow you to initialize the connection, +handle incoming frames from the socket, handle incoming Erlang +messages and then clean up on termination. + +Websocket handlers essentially act as a bridge between the client +and the Erlang system. They will typically do little more than +socket communication and decoding/encoding of frames. + +=== Initialization + +First, the `init/2` callback is called. This callback is common +to all handlers. To establish a Websocket connection, this function +must return a `ws` tuple. + +[source,erlang] +---- +init(Req, _Opts) -> + {cowboy_websocket, Req, #state{}}. +---- + +Upon receiving this tuple, Cowboy will switch to the code +that handles Websocket connections and perform the handshake +immediately. + +If the sec-websocket-protocol header was sent with the request +for establishing a Websocket connection, then the Websocket +handler *must* select one of these subprotocol and send it +back to the client, otherwise the client might decide to close +the connection, assuming no correct subprotocol was found. + +[source,erlang] +---- +init(Req, _Opts) -> + case cowboy_req:parse_header(<<"sec-websocket-protocol">>, Req) of + undefined -> + {ok, Req, #state{}}; + Subprotocols -> + case lists:keymember(<<"mychat2">>, 1, Subprotocols) of + true -> + Req2 = cowboy_req:set_resp_header(<<"sec-websocket-protocol">>, + <<"mychat2">>, Req), + {ok, Req2, #state{}}; + false -> + {stop, Req, undefined} + end + end. +---- + +It is not recommended to wait too long inside the `init/2` +function. Any extra initialization may be done after returning by +sending yourself a message before doing anything. Any message sent +to `self()` from `init/2` is guaranteed to arrive before +any frames from the client. + +It is also very easy to ensure that this message arrives before +any message from other processes by sending it before registering +or enabling timers. + +[source,erlang] +---- +init(Req, _Opts) -> + self() ! post_init, + %% Register process here... + {cowboy_websocket, Req, #state{}}. + +websocket_info(post_init, Req, State) -> + %% Perform post_init initialization here... + {ok, Req, State}. +---- + +=== Handling frames from the client + +Cowboy will call `websocket_handle/3` whenever a text, binary, +ping or pong frame arrives from the client. Note that in the +case of ping and pong frames, no action is expected as Cowboy +automatically replies to ping frames. + +The handler can decide to send frames to the socket, stop +or just continue without sending anything. + +The following snippet echoes back any text frame received and +ignores all others. + +[source,erlang] +---- +websocket_handle(Frame = {text, _}, Req, State) -> + {reply, Frame, Req, State}; +websocket_handle(_Frame, Req, State) -> + {ok, Req, State}. +---- + +=== Handling Erlang messages + +Cowboy will call `websocket_info/3` whenever an Erlang message +arrives. + +The handler can decide to send frames to the socket, stop +or just continue without sending anything. + +The following snippet forwards any `log` message to the socket +and ignores all others. + +[source,erlang] +---- +websocket_info({log, Text}, Req, State) -> + {reply, {text, Text}, Req, State}; +websocket_info(_Info, Req, State) -> + {ok, Req, State}. +---- + +=== Sending frames to the socket + +Cowboy allows sending either a single frame or a list of +frames to the socket, in which case the frames are sent +sequentially. Any frame can be sent: text, binary, ping, +pong or close frames. + +The following example sends three frames using a single `reply` +tuple. + +[source,erlang] +---- +websocket_info(hello_world, Req, State) -> + {reply, [ + {text, "Hello"}, + {text, <<"world!">>}, + {binary, <<0:8000>>} + ], Req, State}; +%% More websocket_info/3 clauses here... +---- + +Note that the payload for text and binary frames is of type +`iodata()`, meaning it can be either a `binary()` or an +`iolist()`. + +Sending a `close` frame will immediately initiate the closing +of the Websocket connection. Be aware that any additional +frames sent by the client or any Erlang messages waiting to +be received will not be processed. Also note that when replying +a list of frames that includes close, any frame found after the +close frame will not be sent. + +=== Ping and timeout + +The biggest performance improvement you can do when dealing +with a huge number of Websocket connections is to reduce the +number of timers that are started on the server. A common use +of timers when dealing with connections is for sending a ping +every once in a while. This should be done exclusively on the +client side. Indeed, a server handling one million Websocket +connections will perform a lot better when it doesn't have to +handle one million extra timers too! + +Cowboy will automatically respond to ping frames sent by the +client. It will still forward the frame to the handler for +informative purpose, but no further action is required. + +Cowboy can be configured to automatically close the Websocket +connection when no data arrives on the socket. It is highly +recommended to configure a timeout for it, as otherwise you +may end up with zombie "half-connected" sockets that may +leave the process alive forever. + +A good timeout value is 60 seconds. + +[source,erlang] +---- +init(Req, _Opts) -> + {cowboy_websocket, Req, #state{}, 60000}. +---- + +This value cannot be changed once it is set. It defaults to +`infinity`. + +=== Hibernate + +Most tuples returned from handler callbacks can include an +extra value `hibernate`. After doing any necessary operations +following the return of the callback, Cowboy will hibernate +the process. + +It is highly recommended to hibernate processes that do not +handle much traffic. It is a good idea to hibernate all +connections by default and investigate only when you start +noticing increased CPU usage. + +=== Supporting older browsers + +Unfortunately Websocket is a relatively recent technology, +which means that not all browsers support it. A library like +https://github.com/ninenines/bullet[Bullet] can be used to +emulate Websocket connections on older browsers. diff --git a/docs/en/cowboy/2.0/guide/ws_handlers/index.html b/docs/en/cowboy/2.0/guide/ws_handlers/index.html new file mode 100644 index 00000000..4bdd00d9 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/ws_handlers/index.html @@ -0,0 +1,339 @@ +<!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"> + + <meta name="generator" content="Hugo 0.15" /> + + <title>Nine Nines: Handling Websocket connections</title> + + <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'> + + <link href="/css/bootstrap.min.css" rel="stylesheet"> + <link href="/css/99s.css" 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="Keep in touch!" href="http://twitter.com/lhoguin"><img src="/img/ico_microblog.png" data-hover="/img/ico_microblog_alt.png"></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>Handling Websocket connections</span></h1> + +<div class="paragraph"><p>A special handler is required for handling Websocket connections.
+Websocket handlers allow you to initialize the connection,
+handle incoming frames from the socket, handle incoming Erlang
+messages and then clean up on termination.</p></div>
+<div class="paragraph"><p>Websocket handlers essentially act as a bridge between the client
+and the Erlang system. They will typically do little more than
+socket communication and decoding/encoding of frames.</p></div>
+<div class="sect1">
+<h2 id="_initialization">Initialization</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>First, the <code>init/2</code> callback is called. This callback is common
+to all handlers. To establish a Websocket connection, this function
+must return a <code>ws</code> tuple.</p></div>
+<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">init</span></span>(<span style="color: #009900">Req</span>, <span style="color: #009900">_Opts</span>) <span style="color: #990000">-></span>
+ {<span style="color: #FF6600">cowboy_websocket</span>, <span style="color: #009900">Req</span>, <span style="color: #008080">#state</span>{}}<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>Upon receiving this tuple, Cowboy will switch to the code
+that handles Websocket connections and perform the handshake
+immediately.</p></div>
+<div class="paragraph"><p>If the sec-websocket-protocol header was sent with the request
+for establishing a Websocket connection, then the Websocket
+handler <strong>must</strong> select one of these subprotocol and send it
+back to the client, otherwise the client might decide to close
+the connection, assuming no correct subprotocol was found.</p></div>
+<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">init</span></span>(<span style="color: #009900">Req</span>, <span style="color: #009900">_Opts</span>) <span style="color: #990000">-></span>
+ <span style="font-weight: bold"><span style="color: #0000FF">case</span></span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:parse_header</span></span>(<span style="color: #990000"><<</span><span style="color: #FF0000">"sec-websocket-protocol"</span><span style="color: #990000">>></span>, <span style="color: #009900">Req</span>) <span style="font-weight: bold"><span style="color: #0000FF">of</span></span>
+ <span style="color: #000080">undefined</span> <span style="color: #990000">-></span>
+ {<span style="color: #FF6600">ok</span>, <span style="color: #009900">Req</span>, <span style="color: #008080">#state</span>{}};
+ <span style="color: #009900">Subprotocols</span> <span style="color: #990000">-></span>
+ <span style="font-weight: bold"><span style="color: #0000FF">case</span></span> <span style="font-weight: bold"><span style="color: #000000">lists:keymember</span></span>(<span style="color: #990000"><<</span><span style="color: #FF0000">"mychat2"</span><span style="color: #990000">>></span>, <span style="color: #993399">1</span>, <span style="color: #009900">Subprotocols</span>) <span style="font-weight: bold"><span style="color: #0000FF">of</span></span>
+ <span style="color: #000080">true</span> <span style="color: #990000">-></span>
+ <span style="color: #009900">Req2</span> <span style="color: #990000">=</span> <span style="font-weight: bold"><span style="color: #000000">cowboy_req:set_resp_header</span></span>(<span style="color: #990000"><<</span><span style="color: #FF0000">"sec-websocket-protocol"</span><span style="color: #990000">>></span>,
+ <span style="color: #990000"><<</span><span style="color: #FF0000">"mychat2"</span><span style="color: #990000">>></span>, <span style="color: #009900">Req</span>),
+ {<span style="color: #FF6600">ok</span>, <span style="color: #009900">Req2</span>, <span style="color: #008080">#state</span>{}};
+ <span style="color: #000080">false</span> <span style="color: #990000">-></span>
+ {<span style="color: #FF6600">stop</span>, <span style="color: #009900">Req</span>, <span style="color: #000080">undefined</span>}
+ <span style="font-weight: bold"><span style="color: #0000FF">end</span></span>
+ <span style="font-weight: bold"><span style="color: #0000FF">end</span></span><span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>It is not recommended to wait too long inside the <code>init/2</code>
+function. Any extra initialization may be done after returning by
+sending yourself a message before doing anything. Any message sent
+to <code>self()</code> from <code>init/2</code> is guaranteed to arrive before
+any frames from the client.</p></div>
+<div class="paragraph"><p>It is also very easy to ensure that this message arrives before
+any message from other processes by sending it before registering
+or enabling timers.</p></div>
+<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">init</span></span>(<span style="color: #009900">Req</span>, <span style="color: #009900">_Opts</span>) <span style="color: #990000">-></span>
+ <span style="font-weight: bold"><span style="color: #000080">self</span></span>() <span style="color: #990000">!</span> <span style="color: #FF6600">post_init</span>,
+ <span style="font-style: italic"><span style="color: #9A1900">%% Register process here...</span></span>
+ {<span style="color: #FF6600">cowboy_websocket</span>, <span style="color: #009900">Req</span>, <span style="color: #008080">#state</span>{}}<span style="color: #990000">.</span>
+
+<span style="font-weight: bold"><span style="color: #000000">websocket_info</span></span>(<span style="color: #FF6600">post_init</span>, <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>) <span style="color: #990000">-></span>
+ <span style="font-style: italic"><span style="color: #9A1900">%% Perform post_init initialization here...</span></span>
+ {<span style="color: #FF6600">ok</span>, <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>}<span style="color: #990000">.</span></tt></pre></div></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_handling_frames_from_the_client">Handling frames from the client</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Cowboy will call <code>websocket_handle/3</code> whenever a text, binary,
+ping or pong frame arrives from the client. Note that in the
+case of ping and pong frames, no action is expected as Cowboy
+automatically replies to ping frames.</p></div>
+<div class="paragraph"><p>The handler can decide to send frames to the socket, stop
+or just continue without sending anything.</p></div>
+<div class="paragraph"><p>The following snippet echoes back any text frame received and
+ignores all others.</p></div>
+<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">websocket_handle</span></span>(<span style="color: #009900">Frame</span> <span style="color: #990000">=</span> {<span style="color: #FF6600">text</span>, <span style="color: #990000">_</span>}, <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>) <span style="color: #990000">-></span>
+ {<span style="color: #FF6600">reply</span>, <span style="color: #009900">Frame</span>, <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>};
+<span style="font-weight: bold"><span style="color: #000000">websocket_handle</span></span>(<span style="color: #009900">_Frame</span>, <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>) <span style="color: #990000">-></span>
+ {<span style="color: #FF6600">ok</span>, <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>}<span style="color: #990000">.</span></tt></pre></div></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_handling_erlang_messages">Handling Erlang messages</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Cowboy will call <code>websocket_info/3</code> whenever an Erlang message
+arrives.</p></div>
+<div class="paragraph"><p>The handler can decide to send frames to the socket, stop
+or just continue without sending anything.</p></div>
+<div class="paragraph"><p>The following snippet forwards any <code>log</code> message to the socket
+and ignores all others.</p></div>
+<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">websocket_info</span></span>({<span style="font-weight: bold"><span style="color: #000080">log</span></span>, <span style="color: #009900">Text</span>}, <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>) <span style="color: #990000">-></span>
+ {<span style="color: #FF6600">reply</span>, {<span style="color: #FF6600">text</span>, <span style="color: #009900">Text</span>}, <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>};
+<span style="font-weight: bold"><span style="color: #000000">websocket_info</span></span>(<span style="color: #009900">_Info</span>, <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>) <span style="color: #990000">-></span>
+ {<span style="color: #FF6600">ok</span>, <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>}<span style="color: #990000">.</span></tt></pre></div></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_sending_frames_to_the_socket">Sending frames to the socket</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Cowboy allows sending either a single frame or a list of
+frames to the socket, in which case the frames are sent
+sequentially. Any frame can be sent: text, binary, ping,
+pong or close frames.</p></div>
+<div class="paragraph"><p>The following example sends three frames using a single <code>reply</code>
+tuple.</p></div>
+<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">websocket_info</span></span>(<span style="color: #FF6600">hello_world</span>, <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>) <span style="color: #990000">-></span>
+ {<span style="color: #FF6600">reply</span>, [
+ {<span style="color: #FF6600">text</span>, <span style="color: #FF0000">"Hello"</span>},
+ {<span style="color: #FF6600">text</span>, <span style="color: #990000"><<</span><span style="color: #FF0000">"world!"</span><span style="color: #990000">>></span>},
+ {<span style="font-weight: bold"><span style="color: #000080">binary</span></span>, <span style="color: #990000"><<</span><span style="color: #993399">0</span><span style="color: #990000">:</span><span style="color: #993399">8000</span><span style="color: #990000">>></span>}
+ ], <span style="color: #009900">Req</span>, <span style="color: #009900">State</span>};
+<span style="font-style: italic"><span style="color: #9A1900">%% More websocket_info/3 clauses here...</span></span></tt></pre></div></div>
+<div class="paragraph"><p>Note that the payload for text and binary frames is of type
+<code>iodata()</code>, meaning it can be either a <code>binary()</code> or an
+<code>iolist()</code>.</p></div>
+<div class="paragraph"><p>Sending a <code>close</code> frame will immediately initiate the closing
+of the Websocket connection. Be aware that any additional
+frames sent by the client or any Erlang messages waiting to
+be received will not be processed. Also note that when replying
+a list of frames that includes close, any frame found after the
+close frame will not be sent.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_ping_and_timeout">Ping and timeout</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>The biggest performance improvement you can do when dealing
+with a huge number of Websocket connections is to reduce the
+number of timers that are started on the server. A common use
+of timers when dealing with connections is for sending a ping
+every once in a while. This should be done exclusively on the
+client side. Indeed, a server handling one million Websocket
+connections will perform a lot better when it doesn’t have to
+handle one million extra timers too!</p></div>
+<div class="paragraph"><p>Cowboy will automatically respond to ping frames sent by the
+client. It will still forward the frame to the handler for
+informative purpose, but no further action is required.</p></div>
+<div class="paragraph"><p>Cowboy can be configured to automatically close the Websocket
+connection when no data arrives on the socket. It is highly
+recommended to configure a timeout for it, as otherwise you
+may end up with zombie "half-connected" sockets that may
+leave the process alive forever.</p></div>
+<div class="paragraph"><p>A good timeout value is 60 seconds.</p></div>
+<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">init</span></span>(<span style="color: #009900">Req</span>, <span style="color: #009900">_Opts</span>) <span style="color: #990000">-></span>
+ {<span style="color: #FF6600">cowboy_websocket</span>, <span style="color: #009900">Req</span>, <span style="color: #008080">#state</span>{}, <span style="color: #993399">60000</span>}<span style="color: #990000">.</span></tt></pre></div></div>
+<div class="paragraph"><p>This value cannot be changed once it is set. It defaults to
+<code>infinity</code>.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_hibernate">Hibernate</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Most tuples returned from handler callbacks can include an
+extra value <code>hibernate</code>. After doing any necessary operations
+following the return of the callback, Cowboy will hibernate
+the process.</p></div>
+<div class="paragraph"><p>It is highly recommended to hibernate processes that do not
+handle much traffic. It is a good idea to hibernate all
+connections by default and investigate only when you start
+noticing increased CPU usage.</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_supporting_older_browsers">Supporting older browsers</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Unfortunately Websocket is a relatively recent technology,
+which means that not all browsers support it. A library like
+<a href="https://github.com/ninenines/bullet">Bullet</a> can be used to
+emulate Websocket connections on older browsers.</p></div>
+</div>
+</div>
+ + + +</div> + +<div class="span3 sidecol"> + + +<h3> + Cowboy + 2.0 + + User Guide +</h3> + +<ul> + + <li><a href="/docs/en/cowboy/2.0/guide">User Guide</a></li> + + + <li><a href="/docs/en/cowboy/2.0/manual">Function Reference</a></li> + + +</ul> + +<h4 id="docs-nav">Navigation</h4> + +<h4>Version select</h4> +<ul> + + + + <li><a href="/docs/en/cowboy/1.0/guide">1.0</a></li> + + <li><a href="/docs/en/cowboy/2.0/guide">2.0</a></li> + +</ul> + +</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 © Loïc Hoguin 2012-2016</p> + </div> + </div> + </div> + </footer> + + + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> + <script src="/js/bootstrap-carousel.js"></script> + <script src="/js/bootstrap-dropdown.js"></script> + <script src="/js/custom.js"></script> + </body> +</html> + + diff --git a/docs/en/cowboy/2.0/guide/ws_protocol.asciidoc b/docs/en/cowboy/2.0/guide/ws_protocol.asciidoc new file mode 100644 index 00000000..67b2cdf2 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/ws_protocol.asciidoc @@ -0,0 +1,43 @@ +[[ws_protocol]] +== The Websocket protocol + +This chapter explains what Websocket is and why it is +a vital component of soft realtime Web applications. + +=== Description + +Websocket is an extension to HTTP that emulates plain TCP +connections between the client, typically a Web browser, +and the server. It uses the HTTP Upgrade mechanism to +establish the connection. + +Websocket connections are asynchronous, unlike HTTP. This +means that not only can the client send frames to the server +at any time, but the server can also send frames to the client +without the client initiating anything other than the +Websocket connection itself. This allows the server to push +data to the client directly. + +Websocket is an IETF standard. Cowboy supports the standard +and all drafts that were previously implemented by browsers, +excluding the initial flawed draft sometimes known as +"version 0". + +=== Implementation + +Cowboy implements Websocket as a protocol upgrade. Once the +upgrade is performed from the `init/2` callback, Cowboy +switches to Websocket. Please consult the next chapter for +more information on initiating and handling Websocket +connections. + +The implementation of Websocket in Cowboy is validated using +the Autobahn test suite, which is an extensive suite of tests +covering all aspects of the protocol. Cowboy passes the +suite with 100% success, including all optional tests. + +Cowboy's Websocket implementation also includes the +x-webkit-deflate-frame compression draft which is being used +by some browsers to reduce the size of data being transmitted. +Cowboy will automatically use compression as long as the +`compress` protocol option is set when starting the listener. diff --git a/docs/en/cowboy/2.0/guide/ws_protocol/index.html b/docs/en/cowboy/2.0/guide/ws_protocol/index.html new file mode 100644 index 00000000..70ba4917 --- /dev/null +++ b/docs/en/cowboy/2.0/guide/ws_protocol/index.html @@ -0,0 +1,182 @@ +<!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"> + + <meta name="generator" content="Hugo 0.15" /> + + <title>Nine Nines: The Websocket protocol</title> + + <link href='http://fonts.googleapis.com/css?family=Open+Sans:400,700,400italic' rel='stylesheet' type='text/css'> + + <link href="/css/bootstrap.min.css" rel="stylesheet"> + <link href="/css/99s.css" 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="Keep in touch!" href="http://twitter.com/lhoguin"><img src="/img/ico_microblog.png" data-hover="/img/ico_microblog_alt.png"></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>The Websocket protocol</span></h1> + +<div class="paragraph"><p>This chapter explains what Websocket is and why it is
+a vital component of soft realtime Web applications.</p></div>
+<div class="sect1">
+<h2 id="_description">Description</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Websocket is an extension to HTTP that emulates plain TCP
+connections between the client, typically a Web browser,
+and the server. It uses the HTTP Upgrade mechanism to
+establish the connection.</p></div>
+<div class="paragraph"><p>Websocket connections are asynchronous, unlike HTTP. This
+means that not only can the client send frames to the server
+at any time, but the server can also send frames to the client
+without the client initiating anything other than the
+Websocket connection itself. This allows the server to push
+data to the client directly.</p></div>
+<div class="paragraph"><p>Websocket is an IETF standard. Cowboy supports the standard
+and all drafts that were previously implemented by browsers,
+excluding the initial flawed draft sometimes known as
+"version 0".</p></div>
+</div>
+</div>
+<div class="sect1">
+<h2 id="_implementation">Implementation</h2>
+<div class="sectionbody">
+<div class="paragraph"><p>Cowboy implements Websocket as a protocol upgrade. Once the
+upgrade is performed from the <code>init/2</code> callback, Cowboy
+switches to Websocket. Please consult the next chapter for
+more information on initiating and handling Websocket
+connections.</p></div>
+<div class="paragraph"><p>The implementation of Websocket in Cowboy is validated using
+the Autobahn test suite, which is an extensive suite of tests
+covering all aspects of the protocol. Cowboy passes the
+suite with 100% success, including all optional tests.</p></div>
+<div class="paragraph"><p>Cowboy’s Websocket implementation also includes the
+x-webkit-deflate-frame compression draft which is being used
+by some browsers to reduce the size of data being transmitted.
+Cowboy will automatically use compression as long as the
+<code>compress</code> protocol option is set when starting the listener.</p></div>
+</div>
+</div>
+ + + +</div> + +<div class="span3 sidecol"> + + +<h3> + Cowboy + 2.0 + + User Guide +</h3> + +<ul> + + <li><a href="/docs/en/cowboy/2.0/guide">User Guide</a></li> + + + <li><a href="/docs/en/cowboy/2.0/manual">Function Reference</a></li> + + +</ul> + +<h4 id="docs-nav">Navigation</h4> + +<h4>Version select</h4> +<ul> + + + + <li><a href="/docs/en/cowboy/1.0/guide">1.0</a></li> + + <li><a href="/docs/en/cowboy/2.0/guide">2.0</a></li> + +</ul> + +</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 © Loïc Hoguin 2012-2016</p> + </div> + </div> + </div> + </footer> + + + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> + <script src="/js/bootstrap-carousel.js"></script> + <script src="/js/bootstrap-dropdown.js"></script> + <script src="/js/custom.js"></script> + </body> +</html> + + |