Commit e4473424 authored by kiplingw's avatar kiplingw

deploy: 05629072

parent 11d10e19
......@@ -6,12 +6,12 @@
<meta name="generator" content="Docusaurus v2.0.0-beta.1">
<title data-react-helmet="true">Page Not Found | Pistache</title><meta data-react-helmet="true" property="og:title" content="Page Not Found | Pistache"><meta data-react-helmet="true" property="og:url" content="https://pistache.io/404.html"><meta data-react-helmet="true" name="docusaurus_locale" content="en"><meta data-react-helmet="true" name="docusaurus_tag" content="default"><link data-react-helmet="true" rel="shortcut icon" href="/img/logo.png"><link data-react-helmet="true" rel="canonical" href="https://pistache.io/404.html"><link data-react-helmet="true" rel="alternate" href="https://pistache.io/404.html" hreflang="en"><link data-react-helmet="true" rel="alternate" href="https://pistache.io/404.html" hreflang="x-default"><link rel="stylesheet" href="/assets/css/styles.35f9fda9.css">
<link rel="preload" href="/assets/js/runtime~main.53122274.js" as="script">
<link rel="preload" href="/assets/js/main.67d7f0b9.js" as="script">
<link rel="preload" href="/assets/js/main.0163458a.js" as="script">
</head>
<body>
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"light")}()</script><div id="__docusaurus">
<div><a href="#main" class="skipToContent_1oUP shadow--md">Skip to main content</a></div><nav class="navbar navbar--fixed-top"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Navigation bar toggle" class="navbar__toggle clean-btn" type="button" tabindex="0"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/"><img src="/img/logo.png" alt="Pistache logo" class="themedImage_1VuW themedImage--light_3UqQ navbar__logo"><img src="/img/logo.png" alt="Pistache logo" class="themedImage_1VuW themedImage--dark_hz6m navbar__logo"><b class="navbar__title">Pistache</b></a><a class="navbar__item navbar__link" href="/docs/">Docs</a></div><div class="navbar__items navbar__items--right"><a href="https://github.com/pistacheio/pistache" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link header-github-link" aria-label="GitHub repository"></a><div class="react-toggle displayOnlyInLargeViewport_GrZ2 react-toggle--disabled"><div class="react-toggle-track" role="button" tabindex="-1"><div class="react-toggle-track-check"><span class="toggle_71bT">🌜</span></div><div class="react-toggle-track-x"><span class="toggle_71bT">🌞</span></div><div class="react-toggle-thumb"></div></div><input type="checkbox" class="react-toggle-screenreader-only" aria-label="Switch between dark and light mode"></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div><div class="navbar-sidebar"><div class="navbar-sidebar__brand"><a class="navbar__brand" href="/"><img src="/img/logo.png" alt="Pistache logo" class="themedImage_1VuW themedImage--light_3UqQ navbar__logo"><img src="/img/logo.png" alt="Pistache logo" class="themedImage_1VuW themedImage--dark_hz6m navbar__logo"><b class="navbar__title">Pistache</b></a></div><div class="navbar-sidebar__items"><div class="menu"><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" href="/docs/">Docs</a></li><li class="menu__list-item"><a href="https://github.com/pistacheio/pistache" target="_blank" rel="noopener noreferrer" class="menu__link header-github-link" aria-label="GitHub repository"></a></li></ul></div></div></div></nav><div class="main-wrapper"><main class="container margin-vert--xl"><div class="row"><div class="col col--6 col--offset-3"><h1 class="hero__title">Page Not Found</h1><p>We could not find what you were looking for.</p><p>Please contact the owner of the site that linked you to the original URL and let them know their link is broken.</p></div></div></main></div><footer class="footer footer--dark"><div class="container"><div class="row footer__links"><div class="col footer__col"><div class="footer__title">Docs</div><ul class="footer__items"><li class="footer__item"><a class="footer__link-item" href="/docs/">Quickstart</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/http-handler/">User guide</a></li></ul></div><div class="col footer__col"><div class="footer__title">Community</div><ul class="footer__items"><li class="footer__item"><a href="https://stackoverflow.com/questions/tagged/pistache" target="_blank" rel="noopener noreferrer" class="footer__link-item">Stack Overflow</a></li><li class="footer__item"><a href="https://web.libera.chat/#pistache" target="_blank" rel="noopener noreferrer" class="footer__link-item">#pistache on Libera.Chat</a></li></ul></div><div class="col footer__col"><div class="footer__title">More</div><ul class="footer__items"><li class="footer__item"><a href="https://github.com/pistacheio/pistache" target="_blank" rel="noopener noreferrer" class="footer__link-item">GitHub</a></li></ul></div></div><div class="footer__bottom text--center"><div class="footer__copyright">Pistache, 2015 - 2021</div></div></div></footer></div>
<script src="/assets/js/runtime~main.53122274.js"></script>
<script src="/assets/js/main.67d7f0b9.js"></script>
<script src="/assets/js/main.0163458a.js"></script>
</body>
</html>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -6,12 +6,12 @@
<meta name="generator" content="Docusaurus v2.0.0-beta.1">
<title data-react-helmet="true">Asynchronous HTTP programming | Pistache</title><meta data-react-helmet="true" property="og:url" content="https://pistache.io/docs/asynchronous-http-programming"><meta data-react-helmet="true" name="docusaurus_locale" content="en"><meta data-react-helmet="true" name="docusaurus_version" content="current"><meta data-react-helmet="true" name="docusaurus_tag" content="docs-default-current"><meta data-react-helmet="true" property="og:title" content="Asynchronous HTTP programming | Pistache"><meta data-react-helmet="true" name="description" content="&lt;!--"><meta data-react-helmet="true" property="og:description" content="&lt;!--"><link data-react-helmet="true" rel="shortcut icon" href="/img/logo.png"><link data-react-helmet="true" rel="canonical" href="https://pistache.io/docs/asynchronous-http-programming"><link data-react-helmet="true" rel="alternate" href="https://pistache.io/docs/asynchronous-http-programming" hreflang="en"><link data-react-helmet="true" rel="alternate" href="https://pistache.io/docs/asynchronous-http-programming" hreflang="x-default"><link rel="stylesheet" href="/assets/css/styles.35f9fda9.css">
<link rel="preload" href="/assets/js/runtime~main.53122274.js" as="script">
<link rel="preload" href="/assets/js/main.67d7f0b9.js" as="script">
<link rel="preload" href="/assets/js/main.0163458a.js" as="script">
</head>
<body>
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"light")}()</script><div id="__docusaurus">
<div><a href="#main" class="skipToContent_1oUP shadow--md">Skip to main content</a></div><nav class="navbar navbar--fixed-top"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Navigation bar toggle" class="navbar__toggle clean-btn" type="button" tabindex="0"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/"><img src="/img/logo.png" alt="Pistache logo" class="themedImage_1VuW themedImage--light_3UqQ navbar__logo"><img src="/img/logo.png" alt="Pistache logo" class="themedImage_1VuW themedImage--dark_hz6m navbar__logo"><b class="navbar__title">Pistache</b></a><a aria-current="page" class="navbar__item navbar__link navbar__link--active" href="/docs/">Docs</a></div><div class="navbar__items navbar__items--right"><a href="https://github.com/pistacheio/pistache" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link header-github-link" aria-label="GitHub repository"></a><div class="react-toggle displayOnlyInLargeViewport_GrZ2 react-toggle--disabled"><div class="react-toggle-track" role="button" tabindex="-1"><div class="react-toggle-track-check"><span class="toggle_71bT">🌜</span></div><div class="react-toggle-track-x"><span class="toggle_71bT">🌞</span></div><div class="react-toggle-thumb"></div></div><input type="checkbox" class="react-toggle-screenreader-only" aria-label="Switch between dark and light mode"></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div><div class="navbar-sidebar"><div class="navbar-sidebar__brand"><a class="navbar__brand" href="/"><img src="/img/logo.png" alt="Pistache logo" class="themedImage_1VuW themedImage--light_3UqQ navbar__logo"><img src="/img/logo.png" alt="Pistache logo" class="themedImage_1VuW themedImage--dark_hz6m navbar__logo"><b class="navbar__title">Pistache</b></a></div><div class="navbar-sidebar__items"><div class="menu"><ul class="menu__list"><li class="menu__list-item"><a aria-current="page" class="menu__link navbar__link--active" href="/docs/">Docs</a></li><li class="menu__list-item"><a href="https://github.com/pistacheio/pistache" target="_blank" rel="noopener noreferrer" class="menu__link header-github-link" aria-label="GitHub repository"></a></li></ul></div></div></div></nav><div class="main-wrapper docs-wrapper doc-page"><div class="docPage_31aa"><aside class="docSidebarContainer_3Kbt"><div class="sidebar_15mo"><nav class="menu menu--responsive thin-scrollbar menu_Bmed" aria-label="Sidebar navigation"><button aria-label="Open menu" aria-haspopup="true" class="button button--secondary button--sm menu__button" type="button"><svg class="sidebarMenuIcon_fgN0" width="24" height="24" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><ul class="menu__list"><li class="menu__list-item"><a aria-current="page" class="menu__link menu__link--active active" href="/docs/asynchronous-http-programming">Asynchronous HTTP programming</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/headers">Headers</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/http-handler">HTTP handler</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/">Getting started</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/rest-description">REST description</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/routing">Routing</a></li></ul></nav></div></aside><main class="docMainContainer_3ufF"><div class="container padding-top--md padding-bottom--lg docItemWrapper_3FMP"><div class="row"><div class="col docItemCol_3FnS"><div class="docItemContainer_33ec"><article><div class="markdown"><header><h1 class="h1Heading_27L5">Asynchronous HTTP programming</h1></header><p>Interfaces provided by Pistaches are <em>asynchronous</em> and <em>non-blocking</em>. Asynchronous programming allows for code to continue executing even if the result of a given call is not available yet. Calls that provide an asynchronous interface are referred to <em>asynchronous calls</em>.</p><p>An example of such a call is the <code>send()</code> function provided by the <code>ResponseWriter</code> interface. This function returns the number of bytes written to the socket file descriptor associated to the connection. However, instead of returning directly the value to the caller and thus blocking the caller, it wraps the value into a component called a <code>Promise</code>.</p><p>A <code>Promise</code> is the Pistache’s implementation of the <a href="https://promisesaplus.com" target="_blank" rel="noopener noreferrer">Promises/A+</a> standard available in many JavaScript implementations. Simply put, during an asynchronous call, a <code>Promise</code> separates the launch of an asynchronous operation from the retrieval of its result. While the asynchronous might still be running, a <code>Promise&lt;T&gt;</code> is directly returned to the caller to retrieve the final result when it becomes available. A so called continuation can be attach to a <code>Promise</code> to execute a callback when the result becomes available (when the <code>Promise</code> has been resolved or fulfilled).</p><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly cpp"><pre tabindex="0" class="prism-code language-cpp codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token keyword" style="font-style:italic">auto</span><span class="token plain"> res </span><span class="token operator" style="color:rgb(137, 221, 255)">=</span><span class="token plain"> response</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">send</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">Http</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Code</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Ok</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token string" style="color:rgb(195, 232, 141)">&quot;Hello World&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">res</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">then</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">ssize_t bytes</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"> std</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">cout </span><span class="token operator" style="color:rgb(137, 221, 255)">&lt;&lt;</span><span class="token plain"> bytes </span><span class="token operator" style="color:rgb(137, 221, 255)">&lt;&lt;</span><span class="token plain"> </span><span class="token string" style="color:rgb(195, 232, 141)">&quot; bytes have been sent\n&quot;</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> Async</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">NoExcept</span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><p>The <code>then()</code> member is used to attach a callback to the <code>Promise</code>. The first argument is a callable that will be called when the <code>Promise</code> has been <strong>succesfully</strong> resolved. If, for some reason, an error occurs during the asynchronous operation, a <code>Promise</code> can be <strong>rejected</strong> and will then fail. In this case, the second callable will be called. <code>Async::NoExcept</code> is a special callback that will call <a href="https://en.cppreference.com/w/cpp/error/terminate" target="_blank" rel="noopener noreferrer"><code>std::terminate()</code></a> if the promise failed. This is the equivalent of the <code>noexcept</code> keyword.</p><p>Other generic callbacks can also be used in this case:</p><ul><li><code>Async::IgnoreException</code> will simply ignore the exception and let the program continue</li><li><code>Async::Throw</code> will &quot;rethrow&quot; the exception up to an eventual promise call-chain. This has the same effect than the <code>throw</code> keyword, except that it is suitable for promises</li></ul><p>Exceptions in promises callbacks are propagated through an <code>exception_ptr</code>. Promises can also be chained together to create a whole asynchronous pipeline:</p><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly cpp"><pre tabindex="0" class="prism-code language-cpp codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token keyword" style="font-style:italic">auto</span><span class="token plain"> fetchOp </span><span class="token operator" style="color:rgb(137, 221, 255)">=</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">fetchDatabase</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">fetchOp</span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">then</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token keyword" style="font-style:italic">const</span><span class="token plain"> User</span><span class="token operator" style="color:rgb(137, 221, 255)">&amp;</span><span class="token plain"> user</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"> </span><span class="token keyword" style="font-style:italic">return</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">fetchUserInfo</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">user</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> Async</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Throw</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">then</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token keyword" style="font-style:italic">const</span><span class="token plain"> UserInfo</span><span class="token operator" style="color:rgb(137, 221, 255)">&amp;</span><span class="token plain"> info</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"> std</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">cout </span><span class="token operator" style="color:rgb(137, 221, 255)">&lt;&lt;</span><span class="token plain"> </span><span class="token string" style="color:rgb(195, 232, 141)">&quot;User name = &quot;</span><span class="token plain"> </span><span class="token operator" style="color:rgb(137, 221, 255)">&lt;&lt;</span><span class="token plain"> info</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">name </span><span class="token operator" style="color:rgb(137, 221, 255)">&lt;&lt;</span><span class="token plain"> </span><span class="token string" style="color:rgb(195, 232, 141)">&#x27;\n&#x27;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">exception_ptr ptr</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"> std</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">cerr </span><span class="token operator" style="color:rgb(137, 221, 255)">&lt;&lt;</span><span class="token plain"> </span><span class="token string" style="color:rgb(195, 232, 141)">&quot;An exception occured during user retrieval\n&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><p>Line 5 will propagate the exception if <code>fetchDatabase()</code> failed and rejected the promise.</p></div><footer class="row docusaurus-mt-lg"><div class="col"><a href="https://github.com/pistacheio/pistache/edit/master/pistache.io/docs/asynchronous-http-programming.md" target="_blank" rel="noreferrer noopener"><svg fill="currentColor" height="20" width="20" viewBox="0 0 40 40" class="iconEdit_2_ui" aria-hidden="true"><g><path d="m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"></path></g></svg>Edit this page</a></div><div class="col lastUpdated_3DPF"></div></footer></article><nav class="pagination-nav docusaurus-mt-lg" aria-label="Docs pages navigation"><div class="pagination-nav__item"></div><div class="pagination-nav__item pagination-nav__item--next"><a class="pagination-nav__link" href="/docs/headers"><div class="pagination-nav__sublabel">Next</div><div class="pagination-nav__label">Headers »</div></a></div></nav></div></div><div class="col col--3"><div class="tableOfContents_35-E thin-scrollbar"></div></div></div></div></main></div></div><footer class="footer footer--dark"><div class="container"><div class="row footer__links"><div class="col footer__col"><div class="footer__title">Docs</div><ul class="footer__items"><li class="footer__item"><a class="footer__link-item" href="/docs/">Quickstart</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/http-handler/">User guide</a></li></ul></div><div class="col footer__col"><div class="footer__title">Community</div><ul class="footer__items"><li class="footer__item"><a href="https://stackoverflow.com/questions/tagged/pistache" target="_blank" rel="noopener noreferrer" class="footer__link-item">Stack Overflow</a></li><li class="footer__item"><a href="https://web.libera.chat/#pistache" target="_blank" rel="noopener noreferrer" class="footer__link-item">#pistache on Libera.Chat</a></li></ul></div><div class="col footer__col"><div class="footer__title">More</div><ul class="footer__items"><li class="footer__item"><a href="https://github.com/pistacheio/pistache" target="_blank" rel="noopener noreferrer" class="footer__link-item">GitHub</a></li></ul></div></div><div class="footer__bottom text--center"><div class="footer__copyright">Pistache, 2015 - 2021</div></div></div></footer></div>
<script src="/assets/js/runtime~main.53122274.js"></script>
<script src="/assets/js/main.67d7f0b9.js"></script>
<script src="/assets/js/main.0163458a.js"></script>
</body>
</html>
\ No newline at end of file
......@@ -6,7 +6,7 @@
<meta name="generator" content="Docusaurus v2.0.0-beta.1">
<title data-react-helmet="true">Headers | Pistache</title><meta data-react-helmet="true" property="og:url" content="https://pistache.io/docs/headers"><meta data-react-helmet="true" name="docusaurus_locale" content="en"><meta data-react-helmet="true" name="docusaurus_version" content="current"><meta data-react-helmet="true" name="docusaurus_tag" content="docs-default-current"><meta data-react-helmet="true" property="og:title" content="Headers | Pistache"><meta data-react-helmet="true" name="description" content="&lt;!--"><meta data-react-helmet="true" property="og:description" content="&lt;!--"><link data-react-helmet="true" rel="shortcut icon" href="/img/logo.png"><link data-react-helmet="true" rel="canonical" href="https://pistache.io/docs/headers"><link data-react-helmet="true" rel="alternate" href="https://pistache.io/docs/headers" hreflang="en"><link data-react-helmet="true" rel="alternate" href="https://pistache.io/docs/headers" hreflang="x-default"><link rel="stylesheet" href="/assets/css/styles.35f9fda9.css">
<link rel="preload" href="/assets/js/runtime~main.53122274.js" as="script">
<link rel="preload" href="/assets/js/main.67d7f0b9.js" as="script">
<link rel="preload" href="/assets/js/main.0163458a.js" as="script">
</head>
<body>
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"light")}()</script><div id="__docusaurus">
......@@ -16,6 +16,6 @@
</span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token keyword" style="font-style:italic">void</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">parse</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token keyword" style="font-style:italic">const</span><span class="token plain"> std</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">string</span><span class="token operator" style="color:rgb(137, 221, 255)">&amp;</span><span class="token plain"> data</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token keyword" style="font-style:italic">auto</span><span class="token plain"> pos </span><span class="token operator" style="color:rgb(137, 221, 255)">=</span><span class="token plain"> data</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">find</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(195, 232, 141)">&#x27;.&#x27;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token keyword" style="font-style:italic">if</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">pos </span><span class="token operator" style="color:rgb(137, 221, 255)">!=</span><span class="token plain"> std</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">string</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">npos</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> minor </span><span class="token operator" style="color:rgb(137, 221, 255)">=</span><span class="token plain"> std</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token function" style="color:rgb(130, 170, 255)">stoi</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">data</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">substr</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token number" style="color:rgb(247, 140, 108)">0</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> pos</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> major </span><span class="token operator" style="color:rgb(137, 221, 255)">=</span><span class="token plain"> std</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token function" style="color:rgb(130, 170, 255)">stoi</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">data</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">substr</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">pos </span><span class="token operator" style="color:rgb(137, 221, 255)">+</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">1</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain" style="display:inline-block">
</span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token keyword" style="font-style:italic">void</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">write</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">std</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">ostream</span><span class="token operator" style="color:rgb(137, 221, 255)">&amp;</span><span class="token plain"> os</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token keyword" style="font-style:italic">const</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> os </span><span class="token operator" style="color:rgb(137, 221, 255)">&lt;&lt;</span><span class="token plain"> minor </span><span class="token operator" style="color:rgb(137, 221, 255)">&lt;&lt;</span><span class="token plain"> </span><span class="token string" style="color:rgb(195, 232, 141)">&quot;.&quot;</span><span class="token plain"> </span><span class="token operator" style="color:rgb(137, 221, 255)">&lt;&lt;</span><span class="token plain"> major</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"></span><span class="token keyword" style="font-style:italic">private</span><span class="token operator" style="color:rgb(137, 221, 255)">:</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token keyword" style="font-style:italic">int</span><span class="token plain"> minor</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token keyword" style="font-style:italic">int</span><span class="token plain"> major</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><p>And that’s it. Now all we have to do is registering the header to the registry system:</p><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly cpp"><pre tabindex="0" class="prism-code language-cpp codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token plain">Header</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Registry</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">registerHeader</span><span class="token operator" style="color:rgb(137, 221, 255)">&lt;</span><span class="token plain">XProtocolVersion</span><span class="token operator" style="color:rgb(137, 221, 255)">&gt;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><div class="admonition admonition-note alert alert--secondary"><div class="admonition-heading"><h5><span class="admonition-icon"><svg xmlns="http://www.w3.org/2000/svg" width="14" height="16" viewBox="0 0 14 16"><path fill-rule="evenodd" d="M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"></path></svg></span>Header instantation</h5></div><div class="admonition-content"><p>You should always provide a default constructor for your header so that it can be instantiated by the registry system</p></div></div><p>Now, the <code>XProtocolVersion</code> can be retrieved and added like any other header in the <code>Header::Collection</code> class.</p><div class="admonition admonition-note alert alert--secondary"><div class="admonition-heading"><h5><span class="admonition-icon"><svg xmlns="http://www.w3.org/2000/svg" width="14" height="16" viewBox="0 0 14 16"><path fill-rule="evenodd" d="M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"></path></svg></span>Unknown headers</h5></div><div class="admonition-content"><p>Headers that are not known to the registry system are stored as a raw pair of strings in the <code>Collection</code> class. <code>getRaw()</code> can be used to retrieve a raw header:</p><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly cpp"><pre tabindex="0" class="prism-code language-cpp codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token keyword" style="font-style:italic">auto</span><span class="token plain"> myHeader </span><span class="token operator" style="color:rgb(137, 221, 255)">=</span><span class="token plain"> request</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">headers</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">getRaw</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(195, 232, 141)">&quot;x-raw-header&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">myHeader</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">name</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token comment" style="color:rgb(105, 112, 152);font-style:italic">// x-raw-header</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">myHeader</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">value</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token comment" style="color:rgb(105, 112, 152);font-style:italic">// returns the value of the header as a string</span></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div></div></div><h2><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_2LWZ" id="mime-types"></a>MIME types<a class="hash-link" href="#mime-types" title="Direct link to heading">#</a></h2><p><a href="https://en.wikipedia.org/wiki/Media_type" target="_blank" rel="noopener noreferrer">MIME Types</a> (or Media Type) are also fully typed. Such types are for example used in an HTTP request or response to describe the data contained in the body of the message (<code>Content-Type</code> header, …) and are composed of a <em>type</em>, <em>subtype</em>, and optional <em>suffix</em> and parameters.</p><p>MIME Types are represented by the <code>Mime::MediaType</code> class, implemented in the <code>mime.h</code> header. A MIME type can be directly constructed from a string:</p><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly cpp"><pre tabindex="0" class="prism-code language-cpp codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token keyword" style="font-style:italic">auto</span><span class="token plain"> mime </span><span class="token operator" style="color:rgb(137, 221, 255)">=</span><span class="token plain"> Http</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Mime</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token class-name" style="color:rgb(255, 203, 107)">MediaType</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token function" style="color:rgb(130, 170, 255)">fromString</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(195, 232, 141)">&quot;application/json&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><p>However, to enforce type-safety, common types are all represented as enumerations:</p><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly cpp"><pre tabindex="0" class="prism-code language-cpp codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token plain">Http</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Mime</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">MediaType </span><span class="token function" style="color:rgb(130, 170, 255)">m1</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">Http</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Mime</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Type</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Application</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> Http</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Mime</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Subtype</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Json</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><p>To avoid such a typing pain, a <code>MIME</code> macro is also provided:</p><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly cpp"><pre tabindex="0" class="prism-code language-cpp codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token keyword" style="font-style:italic">auto</span><span class="token plain"> m1 </span><span class="token operator" style="color:rgb(137, 221, 255)">=</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">MIME</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">Application</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> Json</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><p>For suffix MIMEs, use the special <code>MIME3</code> macro:</p><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly cpp"><pre tabindex="0" class="prism-code language-cpp codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token keyword" style="font-style:italic">auto</span><span class="token plain"> m1 </span><span class="token operator" style="color:rgb(137, 221, 255)">=</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">MIME3</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">Application</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> Json</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> Zip</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><p>If you like typing, you can also use the long form:</p><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly cpp"><pre tabindex="0" class="prism-code language-cpp codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token plain">Http</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Mime</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">MediaType </span><span class="token function" style="color:rgb(130, 170, 255)">m1</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">Http</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Mime</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Type</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Application</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> Http</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Mime</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Subtype</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Json</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> Http</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Mime</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Suffix</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Zip</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><p>The <code>toString()</code> function can be used to get the string representation of a given MIME type:</p><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly cpp"><pre tabindex="0" class="prism-code language-cpp codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token keyword" style="font-style:italic">auto</span><span class="token plain"> m1 </span><span class="token operator" style="color:rgb(137, 221, 255)">=</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">MIME</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">Text</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> Html</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">m1</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">toString</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token comment" style="color:rgb(105, 112, 152);font-style:italic">// text/html</span></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div></div><footer class="row docusaurus-mt-lg"><div class="col"><a href="https://github.com/pistacheio/pistache/edit/master/pistache.io/docs/headers.md" target="_blank" rel="noreferrer noopener"><svg fill="currentColor" height="20" width="20" viewBox="0 0 40 40" class="iconEdit_2_ui" aria-hidden="true"><g><path d="m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"></path></g></svg>Edit this page</a></div><div class="col lastUpdated_3DPF"></div></footer></article><nav class="pagination-nav docusaurus-mt-lg" aria-label="Docs pages navigation"><div class="pagination-nav__item"><a class="pagination-nav__link" href="/docs/asynchronous-http-programming"><div class="pagination-nav__sublabel">Previous</div><div class="pagination-nav__label">« Asynchronous HTTP programming</div></a></div><div class="pagination-nav__item pagination-nav__item--next"><a class="pagination-nav__link" href="/docs/http-handler"><div class="pagination-nav__sublabel">Next</div><div class="pagination-nav__label">HTTP handler »</div></a></div></nav></div></div><div class="col col--3"><div class="tableOfContents_35-E thin-scrollbar"><ul class="table-of-contents table-of-contents__left-border"><li><a href="#overview" class="table-of-contents__link">Overview</a></li><li><a href="#defining-your-own-header" class="table-of-contents__link">Defining your own header</a></li><li><a href="#mime-types" class="table-of-contents__link">MIME types</a></li></ul></div></div></div></div></main></div></div><footer class="footer footer--dark"><div class="container"><div class="row footer__links"><div class="col footer__col"><div class="footer__title">Docs</div><ul class="footer__items"><li class="footer__item"><a class="footer__link-item" href="/docs/">Quickstart</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/http-handler/">User guide</a></li></ul></div><div class="col footer__col"><div class="footer__title">Community</div><ul class="footer__items"><li class="footer__item"><a href="https://stackoverflow.com/questions/tagged/pistache" target="_blank" rel="noopener noreferrer" class="footer__link-item">Stack Overflow</a></li><li class="footer__item"><a href="https://web.libera.chat/#pistache" target="_blank" rel="noopener noreferrer" class="footer__link-item">#pistache on Libera.Chat</a></li></ul></div><div class="col footer__col"><div class="footer__title">More</div><ul class="footer__items"><li class="footer__item"><a href="https://github.com/pistacheio/pistache" target="_blank" rel="noopener noreferrer" class="footer__link-item">GitHub</a></li></ul></div></div><div class="footer__bottom text--center"><div class="footer__copyright">Pistache, 2015 - 2021</div></div></div></footer></div>
<script src="/assets/js/runtime~main.53122274.js"></script>
<script src="/assets/js/main.67d7f0b9.js"></script>
<script src="/assets/js/main.0163458a.js"></script>
</body>
</html>
\ No newline at end of file
......@@ -6,13 +6,13 @@
<meta name="generator" content="Docusaurus v2.0.0-beta.1">
<title data-react-helmet="true">HTTP handler | Pistache</title><meta data-react-helmet="true" property="og:url" content="https://pistache.io/docs/http-handler"><meta data-react-helmet="true" name="docusaurus_locale" content="en"><meta data-react-helmet="true" name="docusaurus_version" content="current"><meta data-react-helmet="true" name="docusaurus_tag" content="docs-default-current"><meta data-react-helmet="true" property="og:title" content="HTTP handler | Pistache"><meta data-react-helmet="true" name="description" content="&lt;!--"><meta data-react-helmet="true" property="og:description" content="&lt;!--"><link data-react-helmet="true" rel="shortcut icon" href="/img/logo.png"><link data-react-helmet="true" rel="canonical" href="https://pistache.io/docs/http-handler"><link data-react-helmet="true" rel="alternate" href="https://pistache.io/docs/http-handler" hreflang="en"><link data-react-helmet="true" rel="alternate" href="https://pistache.io/docs/http-handler" hreflang="x-default"><link rel="stylesheet" href="/assets/css/styles.35f9fda9.css">
<link rel="preload" href="/assets/js/runtime~main.53122274.js" as="script">
<link rel="preload" href="/assets/js/main.67d7f0b9.js" as="script">
<link rel="preload" href="/assets/js/main.0163458a.js" as="script">
</head>
<body>
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"light")}()</script><div id="__docusaurus">
<div><a href="#main" class="skipToContent_1oUP shadow--md">Skip to main content</a></div><nav class="navbar navbar--fixed-top"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Navigation bar toggle" class="navbar__toggle clean-btn" type="button" tabindex="0"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/"><img src="/img/logo.png" alt="Pistache logo" class="themedImage_1VuW themedImage--light_3UqQ navbar__logo"><img src="/img/logo.png" alt="Pistache logo" class="themedImage_1VuW themedImage--dark_hz6m navbar__logo"><b class="navbar__title">Pistache</b></a><a aria-current="page" class="navbar__item navbar__link navbar__link--active" href="/docs/">Docs</a></div><div class="navbar__items navbar__items--right"><a href="https://github.com/pistacheio/pistache" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link header-github-link" aria-label="GitHub repository"></a><div class="react-toggle displayOnlyInLargeViewport_GrZ2 react-toggle--disabled"><div class="react-toggle-track" role="button" tabindex="-1"><div class="react-toggle-track-check"><span class="toggle_71bT">🌜</span></div><div class="react-toggle-track-x"><span class="toggle_71bT">🌞</span></div><div class="react-toggle-thumb"></div></div><input type="checkbox" class="react-toggle-screenreader-only" aria-label="Switch between dark and light mode"></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div><div class="navbar-sidebar"><div class="navbar-sidebar__brand"><a class="navbar__brand" href="/"><img src="/img/logo.png" alt="Pistache logo" class="themedImage_1VuW themedImage--light_3UqQ navbar__logo"><img src="/img/logo.png" alt="Pistache logo" class="themedImage_1VuW themedImage--dark_hz6m navbar__logo"><b class="navbar__title">Pistache</b></a></div><div class="navbar-sidebar__items"><div class="menu"><ul class="menu__list"><li class="menu__list-item"><a aria-current="page" class="menu__link navbar__link--active" href="/docs/">Docs</a></li><li class="menu__list-item"><a href="https://github.com/pistacheio/pistache" target="_blank" rel="noopener noreferrer" class="menu__link header-github-link" aria-label="GitHub repository"></a></li></ul></div></div></div></nav><div class="main-wrapper docs-wrapper doc-page"><div class="docPage_31aa"><aside class="docSidebarContainer_3Kbt"><div class="sidebar_15mo"><nav class="menu menu--responsive thin-scrollbar menu_Bmed" aria-label="Sidebar navigation"><button aria-label="Open menu" aria-haspopup="true" class="button button--secondary button--sm menu__button" type="button"><svg class="sidebarMenuIcon_fgN0" width="24" height="24" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" href="/docs/asynchronous-http-programming">Asynchronous HTTP programming</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/headers">Headers</a></li><li class="menu__list-item"><a aria-current="page" class="menu__link menu__link--active active" href="/docs/http-handler">HTTP handler</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/">Getting started</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/rest-description">REST description</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/routing">Routing</a></li></ul></nav></div></aside><main class="docMainContainer_3ufF"><div class="container padding-top--md padding-bottom--lg docItemWrapper_3FMP"><div class="row"><div class="col docItemCol_3FnS"><div class="docItemContainer_33ec"><article><div class="markdown"><header><h1 class="h1Heading_27L5">HTTP handler</h1></header><p>Requests that are received by Pistache are handled by a special class called <code>Http::Handler</code>. This class declares a bunch of virtual methods that can be overriden to handle special events that occur on the socket and/or connection.</p><p>The <code>onRequest()</code> function must be overriden. This function is called whenever Pistache received data and correctly parsed it as an HTTP request.</p><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly cpp"><pre tabindex="0" class="prism-code language-cpp codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token keyword" style="font-style:italic">virtual</span><span class="token plain"> </span><span class="token keyword" style="font-style:italic">void</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">onRequest</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token keyword" style="font-style:italic">const</span><span class="token plain"> Http</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Request</span><span class="token operator" style="color:rgb(137, 221, 255)">&amp;</span><span class="token plain"> request</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> Http</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">ResponseWriter response</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><p>The first argument is an object of type <code>Http::Request</code> representing the request itself. It contains a bunch of informations including:</p><ul><li>The resource associated to the request</li><li>The query parameters</li><li>The headers</li><li>The body of the request</li></ul><p>The <code>Request</code> object gives a read-only access to these informations. You can access them through a couple of getters but can not modify them. An HTTP request is <strong>immutable</strong>.</p><h2><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_2LWZ" id="sending-a-response"></a>Sending a response<a class="hash-link" href="#sending-a-response" title="Direct link to heading">#</a></h2><p><code>ResponseWriter</code> is an object from which the final HTTP response is sent to the client. The <code>onRequest()</code> function does not return anything (<code>void</code>). Instead, the response is sent through the <code>ResponseWriter</code> class. This class provides a bunch of <code>send()</code> function overloads to send the response:</p><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly cpp"><pre tabindex="0" class="prism-code language-cpp codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token plain">Async</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Promise</span><span class="token operator" style="color:rgb(137, 221, 255)">&lt;</span><span class="token plain">ssize_t</span><span class="token operator" style="color:rgb(137, 221, 255)">&gt;</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">send</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">Code code</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><p>You can use this overload to send a response with an empty body and a given HTTP Code (e.g <code>Http::Code::Ok</code>)</p><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly cpp"><pre tabindex="0" class="prism-code language-cpp codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token plain">Async</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Promise</span><span class="token operator" style="color:rgb(137, 221, 255)">&lt;</span><span class="token plain">ssize_t</span><span class="token operator" style="color:rgb(137, 221, 255)">&gt;</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">send</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> Code code</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token keyword" style="font-style:italic">const</span><span class="token plain"> std</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">string</span><span class="token operator" style="color:rgb(137, 221, 255)">&amp;</span><span class="token plain"> body</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token keyword" style="font-style:italic">const</span><span class="token plain"> Mime</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">MediaType </span><span class="token operator" style="color:rgb(137, 221, 255)">&amp;</span><span class="token plain">mime </span><span class="token operator" style="color:rgb(137, 221, 255)">=</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 107)">Mime</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token function" style="color:rgb(130, 170, 255)">MediaType</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><p>This overload can be used to send a response with static, fixed-size content (body). A MIME type can also be specified, which will be sent through the <code>Content-Type</code> header.</p><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly cpp"><pre tabindex="0" class="prism-code language-cpp codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token keyword" style="font-style:italic">template</span><span class="token operator" style="color:rgb(137, 221, 255)">&lt;</span><span class="token plain">size_t N</span><span class="token operator" style="color:rgb(137, 221, 255)">&gt;</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">Async</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Promise</span><span class="token operator" style="color:rgb(137, 221, 255)">&lt;</span><span class="token plain">ssize_t</span><span class="token operator" style="color:rgb(137, 221, 255)">&gt;</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">send</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> Code code</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token keyword" style="font-style:italic">const</span><span class="token plain"> </span><span class="token keyword" style="font-style:italic">char</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token operator" style="color:rgb(137, 221, 255)">&amp;</span><span class="token plain">arr</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token plain">N</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token keyword" style="font-style:italic">const</span><span class="token plain"> Mime</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">MediaType</span><span class="token operator" style="color:rgb(137, 221, 255)">&amp;</span><span class="token plain"> mime </span><span class="token operator" style="color:rgb(137, 221, 255)">=</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 107)">Mime</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token function" style="color:rgb(130, 170, 255)">MediaType</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><p>This version can also be used to send a fixed-size response with a body except that it does not need to construct a string (no memory is allocated). The size of the content is directly deduced by the compiler. This version only works with raw string literals.</p><p>These functions are asynchronous, meaning that they do not return a plain old <code>ssize_t</code> value indicating the number of bytes being sent, but instead a <code>Promise</code> that will be fulfilled later on. See the next section for more details on asynchronous programming with Pistache.</p><h2><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_2LWZ" id="response-streaming"></a>Response streaming<a class="hash-link" href="#response-streaming" title="Direct link to heading">#</a></h2><p>Sometimes, content that is to be sent back to the user can not be known in advance, thus the length can not be determined in advance. For that matter, the HTTP specification defines a special data-transfer mechanism called <a href="https://tools.ietf.org/html/rfc7230#section-4.1" target="_blank" rel="noopener noreferrer">chunked encoding</a> where data is sent in a series of <em>chunks</em>. This mechanism uses the <code>Transfer-Encoding</code> HTTP header in place of the <code>Content-Length</code> one.</p><p>To stream content, Pistache provides a special <code>ResponseStream</code> class. To get a <code>ResponseStream</code> from a <code>ResponseWriter</code>, call the <code>stream()</code> member function:</p><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly cpp"><pre tabindex="0" class="prism-code language-cpp codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token keyword" style="font-style:italic">auto</span><span class="token plain"> stream </span><span class="token operator" style="color:rgb(137, 221, 255)">=</span><span class="token plain"> response</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">stream</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">Http</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Code</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Ok</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><p>To initate a stream, you have to pass the HTTP status code to the stream function (here <code>Http::Code::Ok</code> or <code>HTTP 200</code>). The <code>ResponseStream</code> class provides an <code>iostream</code> like interface that overloads the <code>&lt;&lt;</code> operator.</p><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly cpp"><pre tabindex="0" class="prism-code language-cpp codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token plain">stream </span><span class="token operator" style="color:rgb(137, 221, 255)">&lt;&lt;</span><span class="token plain"> </span><span class="token string" style="color:rgb(195, 232, 141)">&quot;PO&quot;</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">stream </span><span class="token operator" style="color:rgb(137, 221, 255)">&lt;&lt;</span><span class="token plain"> </span><span class="token string" style="color:rgb(195, 232, 141)">&quot;NG&quot;</span></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><p>The first line will write a chunk of size 2 with the content <em>PO</em> to the stream&#x27;s buffer. The second line will write a second chunk of size 2 with the content <em>NG</em>. To end the stream and flush the content, use the special <code>ends</code> marker:</p><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly cpp"><pre tabindex="0" class="prism-code language-cpp codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token plain">stream </span><span class="token operator" style="color:rgb(137, 221, 255)">&lt;&lt;</span><span class="token plain"> ends</span></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><p>The <code>ends</code> marker will write the last chunk of size 0 and send the final data over the network. To simply flush the stream&#x27;s buffer without ending the stream, you can use the <code>flush</code> marker:</p><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly cpp"><pre tabindex="0" class="prism-code language-cpp codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token plain">stream </span><span class="token operator" style="color:rgb(137, 221, 255)">&lt;&lt;</span><span class="token plain"> flush</span></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><div class="admonition admonition-caution alert alert--warning"><div class="admonition-heading"><h5><span class="admonition-icon"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16"><path fill-rule="evenodd" d="M8.893 1.5c-.183-.31-.52-.5-.887-.5s-.703.19-.886.5L.138 13.499a.98.98 0 0 0 0 1.001c.193.31.53.501.886.501h13.964c.367 0 .704-.19.877-.5a1.03 1.03 0 0 0 .01-1.002L8.893 1.5zm.133 11.497H6.987v-2.003h2.039v2.003zm0-3.004H6.987V5.987h2.039v4.006z"></path></svg></span>Headers writing</h5></div><div class="admonition-content"><p>After starting a stream, headers become immutable. They must be written to the response before creating a <code>ResponseStream</code>:</p><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly cpp"><pre tabindex="0" class="prism-code language-cpp codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token plain">response</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">headers</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">add</span><span class="token operator" style="color:rgb(137, 221, 255)">&lt;</span><span class="token plain">Header</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Server</span><span class="token operator" style="color:rgb(137, 221, 255)">&gt;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(195, 232, 141)">&quot;lys&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">add</span><span class="token operator" style="color:rgb(137, 221, 255)">&lt;</span><span class="token plain">Header</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">ContentType</span><span class="token operator" style="color:rgb(137, 221, 255)">&gt;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token function" style="color:rgb(130, 170, 255)">MIME</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">Text</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> Plain</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain" style="display:inline-block">
</span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"></span><span class="token keyword" style="font-style:italic">auto</span><span class="token plain"> stream </span><span class="token operator" style="color:rgb(137, 221, 255)">=</span><span class="token plain"> response</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">stream</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">stream </span><span class="token operator" style="color:rgb(137, 221, 255)">&lt;&lt;</span><span class="token plain"> </span><span class="token string" style="color:rgb(195, 232, 141)">&quot;PO&quot;</span><span class="token plain"> </span><span class="token operator" style="color:rgb(137, 221, 255)">&lt;&lt;</span><span class="token plain"> </span><span class="token string" style="color:rgb(195, 232, 141)">&quot;NG&quot;</span><span class="token plain"> </span><span class="token operator" style="color:rgb(137, 221, 255)">&lt;&lt;</span><span class="token plain"> ends</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div></div></div><h2><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_2LWZ" id="static-file-serving"></a>Static file serving<a class="hash-link" href="#static-file-serving" title="Direct link to heading">#</a></h2><p>In addition to text content serving, Pistache provides a way to serve static files through the <code>Http::serveFile</code> function:</p><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly cpp"><pre tabindex="0" class="prism-code language-cpp codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token keyword" style="font-style:italic">if</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">request</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">resource</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token operator" style="color:rgb(137, 221, 255)">==</span><span class="token plain"> </span><span class="token string" style="color:rgb(195, 232, 141)">&quot;/doc&quot;</span><span class="token plain"> </span><span class="token operator" style="color:rgb(137, 221, 255)">&amp;&amp;</span><span class="token plain"> request</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">method </span><span class="token operator" style="color:rgb(137, 221, 255)">==</span><span class="token plain"> Http</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Method</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Get</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 107)">Http</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token function" style="color:rgb(130, 170, 255)">serveFile</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">response</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token string" style="color:rgb(195, 232, 141)">&quot;README.md&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><div class="admonition admonition-note alert alert--secondary"><div class="admonition-heading"><h5><span class="admonition-icon"><svg xmlns="http://www.w3.org/2000/svg" width="14" height="16" viewBox="0 0 14 16"><path fill-rule="evenodd" d="M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"></path></svg></span>Return value</h5></div><div class="admonition-content"><p><code>serveFile</code> also returns a <code>Promise</code> representing the total number of bytes being sent to the wire</p></div></div><h2><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_2LWZ" id="controlling-timeout"></a>Controlling timeout<a class="hash-link" href="#controlling-timeout" title="Direct link to heading">#</a></h2><p>Sometimes, you might require to timeout after a certain amount of time. For example, if you are designing an HTTP API with soft real-time constraints, you will have a time constraint to send a response back to the client. That is why Pistache provides the ability to control the timeout on a per-request basis. To arm a timeout on a response, you can use the <code>timeoutAfter()</code> member function directly on the <code>ResponseWriter</code> object:</p><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly cpp"><pre tabindex="0" class="prism-code language-cpp codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token plain">response</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">timeoutAfter</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">std</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">chrono</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token function" style="color:rgb(130, 170, 255)">milliseconds</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token number" style="color:rgb(247, 140, 108)">500</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><p>This will trigger a timeout if a response has not been sent within 500 milliseconds. <code>timeoutAfter</code> accepts any kind of duration.</p><p>When a timeout triggers, the <code>onTimeout()</code> function from your handler will be called. By default, this method does nothing. If you want to handle your timeout properly, you should then override this function inside your own handler:</p><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly cpp"><pre tabindex="0" class="prism-code language-cpp codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token keyword" style="font-style:italic">void</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">onTimeout</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token keyword" style="font-style:italic">const</span><span class="token plain"> Http</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Request</span><span class="token operator" style="color:rgb(137, 221, 255)">&amp;</span><span class="token plain"> request</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> Http</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">ResponseWriter writer</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> request</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">send</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">Http</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Code</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">No_Content</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><p>The <code>Request</code> object that is passed to the <code>onTimeout</code> is the exact same request that triggered the timeout. The <code>ResponseWriter</code> is a complete new writer object.</p><div class="admonition admonition-note alert alert--secondary"><div class="admonition-heading"><h5><span class="admonition-icon"><svg xmlns="http://www.w3.org/2000/svg" width="14" height="16" viewBox="0 0 14 16"><path fill-rule="evenodd" d="M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"></path></svg></span>ResponseWriter state</h5></div><div class="admonition-content"><p>Since the <code>ResponseWriter</code> object is a complete new object, state is not preserved with the <code>ResponseWriter</code> from the <code>onRequest()</code> callback, which means that you will have to write the complete response again, including headers and cookies.</p></div></div></div><footer class="row docusaurus-mt-lg"><div class="col"><a href="https://github.com/pistacheio/pistache/edit/master/pistache.io/docs/http-handler.md" target="_blank" rel="noreferrer noopener"><svg fill="currentColor" height="20" width="20" viewBox="0 0 40 40" class="iconEdit_2_ui" aria-hidden="true"><g><path d="m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"></path></g></svg>Edit this page</a></div><div class="col lastUpdated_3DPF"></div></footer></article><nav class="pagination-nav docusaurus-mt-lg" aria-label="Docs pages navigation"><div class="pagination-nav__item"><a class="pagination-nav__link" href="/docs/headers"><div class="pagination-nav__sublabel">Previous</div><div class="pagination-nav__label">« Headers</div></a></div><div class="pagination-nav__item pagination-nav__item--next"><a class="pagination-nav__link" href="/docs/"><div class="pagination-nav__sublabel">Next</div><div class="pagination-nav__label">Getting started »</div></a></div></nav></div></div><div class="col col--3"><div class="tableOfContents_35-E thin-scrollbar"><ul class="table-of-contents table-of-contents__left-border"><li><a href="#sending-a-response" class="table-of-contents__link">Sending a response</a></li><li><a href="#response-streaming" class="table-of-contents__link">Response streaming</a></li><li><a href="#static-file-serving" class="table-of-contents__link">Static file serving</a></li><li><a href="#controlling-timeout" class="table-of-contents__link">Controlling timeout</a></li></ul></div></div></div></div></main></div></div><footer class="footer footer--dark"><div class="container"><div class="row footer__links"><div class="col footer__col"><div class="footer__title">Docs</div><ul class="footer__items"><li class="footer__item"><a class="footer__link-item" href="/docs/">Quickstart</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/http-handler/">User guide</a></li></ul></div><div class="col footer__col"><div class="footer__title">Community</div><ul class="footer__items"><li class="footer__item"><a href="https://stackoverflow.com/questions/tagged/pistache" target="_blank" rel="noopener noreferrer" class="footer__link-item">Stack Overflow</a></li><li class="footer__item"><a href="https://web.libera.chat/#pistache" target="_blank" rel="noopener noreferrer" class="footer__link-item">#pistache on Libera.Chat</a></li></ul></div><div class="col footer__col"><div class="footer__title">More</div><ul class="footer__items"><li class="footer__item"><a href="https://github.com/pistacheio/pistache" target="_blank" rel="noopener noreferrer" class="footer__link-item">GitHub</a></li></ul></div></div><div class="footer__bottom text--center"><div class="footer__copyright">Pistache, 2015 - 2021</div></div></div></footer></div>
<script src="/assets/js/runtime~main.53122274.js"></script>
<script src="/assets/js/main.67d7f0b9.js"></script>
<script src="/assets/js/main.0163458a.js"></script>
</body>
</html>
\ No newline at end of file
......@@ -6,7 +6,7 @@
<meta name="generator" content="Docusaurus v2.0.0-beta.1">
<title data-react-helmet="true">Getting started | Pistache</title><meta data-react-helmet="true" property="og:url" content="https://pistache.io/docs/"><meta data-react-helmet="true" name="docusaurus_locale" content="en"><meta data-react-helmet="true" name="docusaurus_version" content="current"><meta data-react-helmet="true" name="docusaurus_tag" content="docs-default-current"><meta data-react-helmet="true" property="og:title" content="Getting started | Pistache"><meta data-react-helmet="true" name="description" content="&lt;!--"><meta data-react-helmet="true" property="og:description" content="&lt;!--"><link data-react-helmet="true" rel="shortcut icon" href="/img/logo.png"><link data-react-helmet="true" rel="canonical" href="https://pistache.io/docs/"><link data-react-helmet="true" rel="alternate" href="https://pistache.io/docs/" hreflang="en"><link data-react-helmet="true" rel="alternate" href="https://pistache.io/docs/" hreflang="x-default"><link rel="stylesheet" href="/assets/css/styles.35f9fda9.css">
<link rel="preload" href="/assets/js/runtime~main.53122274.js" as="script">
<link rel="preload" href="/assets/js/main.67d7f0b9.js" as="script">
<link rel="preload" href="/assets/js/main.0163458a.js" as="script">
</head>
<body>
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"light")}()</script><div id="__docusaurus">
......@@ -16,6 +16,6 @@
</span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token keyword" style="font-style:italic">void</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">onRequest</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token keyword" style="font-style:italic">const</span><span class="token plain"> Http</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Request</span><span class="token operator" style="color:rgb(137, 221, 255)">&amp;</span><span class="token plain"> request</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> Http</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">ResponseWriter response</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> response</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">send</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">Http</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Code</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Ok</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token string" style="color:rgb(195, 232, 141)">&quot;Hello, World\n&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><p>Handlers must inherit the <code>Http::Handler</code> class and at least define the <code>onRequest</code> member function. They must also define a <code>clone()</code> member function. Simple handlers can use the special <code>HTTP_PROTOTYPE</code> macro, passing in the name of the class. The macro will take care of defining the <code>clone()</code> member function for you.</p><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_2LWZ" id="final-touch"></a>Final touch<a class="hash-link" href="#final-touch" title="Direct link to heading">#</a></h3><p>After defining the handler, the server can now be started:</p><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly cpp"><pre tabindex="0" class="prism-code language-cpp codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token keyword" style="font-style:italic">int</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">main</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> Address </span><span class="token function" style="color:rgb(130, 170, 255)">addr</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token class-name" style="color:rgb(255, 203, 107)">Ipv4</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token function" style="color:rgb(130, 170, 255)">any</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">Port</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token number" style="color:rgb(247, 140, 108)">9080</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain" style="display:inline-block">
</span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token keyword" style="font-style:italic">auto</span><span class="token plain"> opts </span><span class="token operator" style="color:rgb(137, 221, 255)">=</span><span class="token plain"> Http</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token class-name" style="color:rgb(255, 203, 107)">Endpoint</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token function" style="color:rgb(130, 170, 255)">options</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">threads</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token number" style="color:rgb(247, 140, 108)">1</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> Http</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Endpoint </span><span class="token function" style="color:rgb(130, 170, 255)">server</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">addr</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> server</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">init</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">opts</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> server</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">setHandler</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">Http</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">make_handler</span><span class="token operator" style="color:rgb(137, 221, 255)">&lt;</span><span class="token plain">HelloHandler</span><span class="token operator" style="color:rgb(137, 221, 255)">&gt;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> server</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">serve</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><p>For simplicity, you can also use the special <code>listenAndServe</code> function that will automatically create an endpoint and instantiate your handler:</p><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly cpp"><pre tabindex="0" class="prism-code language-cpp codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token keyword" style="font-style:italic">int</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">main</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> Http</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">listenAndServe</span><span class="token operator" style="color:rgb(137, 221, 255)">&lt;</span><span class="token plain">HelloHandler</span><span class="token operator" style="color:rgb(137, 221, 255)">&gt;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(195, 232, 141)">&quot;*:9080&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><p>And that’s it, now you can fire up your favorite curl request and observe the final result:</p><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly shell"><pre tabindex="0" class="prism-code language-shell codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token function" style="color:rgb(130, 170, 255)">curl</span><span class="token plain"> http://localhost:9080/</span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain">Hello, World</span></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><p>Complete code for this example can be found on GitHub: <a href="https://github.com/pistacheio/pistache/blob/master/examples/hello_server.cc" target="_blank" rel="noopener noreferrer">examples/hello_server.cc</a></p></div><footer class="row docusaurus-mt-lg"><div class="col"><a href="https://github.com/pistacheio/pistache/edit/master/pistache.io/docs/quickstart.md" target="_blank" rel="noreferrer noopener"><svg fill="currentColor" height="20" width="20" viewBox="0 0 40 40" class="iconEdit_2_ui" aria-hidden="true"><g><path d="m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"></path></g></svg>Edit this page</a></div><div class="col lastUpdated_3DPF"></div></footer></article><nav class="pagination-nav docusaurus-mt-lg" aria-label="Docs pages navigation"><div class="pagination-nav__item"><a class="pagination-nav__link" href="/docs/http-handler"><div class="pagination-nav__sublabel">Previous</div><div class="pagination-nav__label">« HTTP handler</div></a></div><div class="pagination-nav__item pagination-nav__item--next"><a class="pagination-nav__link" href="/docs/rest-description"><div class="pagination-nav__sublabel">Next</div><div class="pagination-nav__label">REST description »</div></a></div></nav></div></div><div class="col col--3"><div class="tableOfContents_35-E thin-scrollbar"><ul class="table-of-contents table-of-contents__left-border"><li><a href="#installing-pistache" class="table-of-contents__link">Installing Pistache</a></li><li><a href="#serving-requests" class="table-of-contents__link">Serving requests</a><ul><li><a href="#include" class="table-of-contents__link">Include</a></li><li><a href="#hello-world" class="table-of-contents__link">Hello world</a></li><li><a href="#final-touch" class="table-of-contents__link">Final touch</a></li></ul></li></ul></div></div></div></div></main></div></div><footer class="footer footer--dark"><div class="container"><div class="row footer__links"><div class="col footer__col"><div class="footer__title">Docs</div><ul class="footer__items"><li class="footer__item"><a class="footer__link-item" href="/docs/">Quickstart</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/http-handler/">User guide</a></li></ul></div><div class="col footer__col"><div class="footer__title">Community</div><ul class="footer__items"><li class="footer__item"><a href="https://stackoverflow.com/questions/tagged/pistache" target="_blank" rel="noopener noreferrer" class="footer__link-item">Stack Overflow</a></li><li class="footer__item"><a href="https://web.libera.chat/#pistache" target="_blank" rel="noopener noreferrer" class="footer__link-item">#pistache on Libera.Chat</a></li></ul></div><div class="col footer__col"><div class="footer__title">More</div><ul class="footer__items"><li class="footer__item"><a href="https://github.com/pistacheio/pistache" target="_blank" rel="noopener noreferrer" class="footer__link-item">GitHub</a></li></ul></div></div><div class="footer__bottom text--center"><div class="footer__copyright">Pistache, 2015 - 2021</div></div></div></footer></div>
<script src="/assets/js/runtime~main.53122274.js"></script>
<script src="/assets/js/main.67d7f0b9.js"></script>
<script src="/assets/js/main.0163458a.js"></script>
</body>
</html>
\ No newline at end of file
......@@ -6,12 +6,12 @@
<meta name="generator" content="Docusaurus v2.0.0-beta.1">
<title data-react-helmet="true">REST description | Pistache</title><meta data-react-helmet="true" property="og:url" content="https://pistache.io/docs/rest-description"><meta data-react-helmet="true" name="docusaurus_locale" content="en"><meta data-react-helmet="true" name="docusaurus_version" content="current"><meta data-react-helmet="true" name="docusaurus_tag" content="docs-default-current"><meta data-react-helmet="true" property="og:title" content="REST description | Pistache"><meta data-react-helmet="true" name="description" content="&lt;!--"><meta data-react-helmet="true" property="og:description" content="&lt;!--"><link data-react-helmet="true" rel="shortcut icon" href="/img/logo.png"><link data-react-helmet="true" rel="canonical" href="https://pistache.io/docs/rest-description"><link data-react-helmet="true" rel="alternate" href="https://pistache.io/docs/rest-description" hreflang="en"><link data-react-helmet="true" rel="alternate" href="https://pistache.io/docs/rest-description" hreflang="x-default"><link rel="stylesheet" href="/assets/css/styles.35f9fda9.css">
<link rel="preload" href="/assets/js/runtime~main.53122274.js" as="script">
<link rel="preload" href="/assets/js/main.67d7f0b9.js" as="script">
<link rel="preload" href="/assets/js/main.0163458a.js" as="script">
</head>
<body>
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"light")}()</script><div id="__docusaurus">
<div><a href="#main" class="skipToContent_1oUP shadow--md">Skip to main content</a></div><nav class="navbar navbar--fixed-top"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Navigation bar toggle" class="navbar__toggle clean-btn" type="button" tabindex="0"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/"><img src="/img/logo.png" alt="Pistache logo" class="themedImage_1VuW themedImage--light_3UqQ navbar__logo"><img src="/img/logo.png" alt="Pistache logo" class="themedImage_1VuW themedImage--dark_hz6m navbar__logo"><b class="navbar__title">Pistache</b></a><a aria-current="page" class="navbar__item navbar__link navbar__link--active" href="/docs/">Docs</a></div><div class="navbar__items navbar__items--right"><a href="https://github.com/pistacheio/pistache" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link header-github-link" aria-label="GitHub repository"></a><div class="react-toggle displayOnlyInLargeViewport_GrZ2 react-toggle--disabled"><div class="react-toggle-track" role="button" tabindex="-1"><div class="react-toggle-track-check"><span class="toggle_71bT">🌜</span></div><div class="react-toggle-track-x"><span class="toggle_71bT">🌞</span></div><div class="react-toggle-thumb"></div></div><input type="checkbox" class="react-toggle-screenreader-only" aria-label="Switch between dark and light mode"></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div><div class="navbar-sidebar"><div class="navbar-sidebar__brand"><a class="navbar__brand" href="/"><img src="/img/logo.png" alt="Pistache logo" class="themedImage_1VuW themedImage--light_3UqQ navbar__logo"><img src="/img/logo.png" alt="Pistache logo" class="themedImage_1VuW themedImage--dark_hz6m navbar__logo"><b class="navbar__title">Pistache</b></a></div><div class="navbar-sidebar__items"><div class="menu"><ul class="menu__list"><li class="menu__list-item"><a aria-current="page" class="menu__link navbar__link--active" href="/docs/">Docs</a></li><li class="menu__list-item"><a href="https://github.com/pistacheio/pistache" target="_blank" rel="noopener noreferrer" class="menu__link header-github-link" aria-label="GitHub repository"></a></li></ul></div></div></div></nav><div class="main-wrapper docs-wrapper doc-page"><div class="docPage_31aa"><aside class="docSidebarContainer_3Kbt"><div class="sidebar_15mo"><nav class="menu menu--responsive thin-scrollbar menu_Bmed" aria-label="Sidebar navigation"><button aria-label="Open menu" aria-haspopup="true" class="button button--secondary button--sm menu__button" type="button"><svg class="sidebarMenuIcon_fgN0" width="24" height="24" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" href="/docs/asynchronous-http-programming">Asynchronous HTTP programming</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/headers">Headers</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/http-handler">HTTP handler</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/">Getting started</a></li><li class="menu__list-item"><a aria-current="page" class="menu__link menu__link--active active" href="/docs/rest-description">REST description</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/routing">Routing</a></li></ul></nav></div></aside><main class="docMainContainer_3ufF"><div class="container padding-top--md padding-bottom--lg docItemWrapper_3FMP"><div class="row"><div class="col docItemCol_3FnS"><div class="docItemContainer_33ec"><article><div class="markdown"><header><h1 class="h1Heading_27L5">REST description</h1></header><p>Documentation writing for this part is still in progress, please refer to the <a href="https://github.com/pistacheio/pistache/blob/master/examples/rest_description.cc" target="_blank" rel="noopener noreferrer">rest_description</a> example.</p></div><footer class="row docusaurus-mt-lg"><div class="col"><a href="https://github.com/pistacheio/pistache/edit/master/pistache.io/docs/rest-description.md" target="_blank" rel="noreferrer noopener"><svg fill="currentColor" height="20" width="20" viewBox="0 0 40 40" class="iconEdit_2_ui" aria-hidden="true"><g><path d="m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"></path></g></svg>Edit this page</a></div><div class="col lastUpdated_3DPF"></div></footer></article><nav class="pagination-nav docusaurus-mt-lg" aria-label="Docs pages navigation"><div class="pagination-nav__item"><a class="pagination-nav__link" href="/docs/"><div class="pagination-nav__sublabel">Previous</div><div class="pagination-nav__label">« Getting started</div></a></div><div class="pagination-nav__item pagination-nav__item--next"><a class="pagination-nav__link" href="/docs/routing"><div class="pagination-nav__sublabel">Next</div><div class="pagination-nav__label">Routing »</div></a></div></nav></div></div><div class="col col--3"><div class="tableOfContents_35-E thin-scrollbar"></div></div></div></div></main></div></div><footer class="footer footer--dark"><div class="container"><div class="row footer__links"><div class="col footer__col"><div class="footer__title">Docs</div><ul class="footer__items"><li class="footer__item"><a class="footer__link-item" href="/docs/">Quickstart</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/http-handler/">User guide</a></li></ul></div><div class="col footer__col"><div class="footer__title">Community</div><ul class="footer__items"><li class="footer__item"><a href="https://stackoverflow.com/questions/tagged/pistache" target="_blank" rel="noopener noreferrer" class="footer__link-item">Stack Overflow</a></li><li class="footer__item"><a href="https://web.libera.chat/#pistache" target="_blank" rel="noopener noreferrer" class="footer__link-item">#pistache on Libera.Chat</a></li></ul></div><div class="col footer__col"><div class="footer__title">More</div><ul class="footer__items"><li class="footer__item"><a href="https://github.com/pistacheio/pistache" target="_blank" rel="noopener noreferrer" class="footer__link-item">GitHub</a></li></ul></div></div><div class="footer__bottom text--center"><div class="footer__copyright">Pistache, 2015 - 2021</div></div></div></footer></div>
<script src="/assets/js/runtime~main.53122274.js"></script>
<script src="/assets/js/main.67d7f0b9.js"></script>
<script src="/assets/js/main.0163458a.js"></script>
</body>
</html>
\ No newline at end of file
......@@ -6,13 +6,13 @@
<meta name="generator" content="Docusaurus v2.0.0-beta.1">
<title data-react-helmet="true">Routing | Pistache</title><meta data-react-helmet="true" property="og:url" content="https://pistache.io/docs/routing"><meta data-react-helmet="true" name="docusaurus_locale" content="en"><meta data-react-helmet="true" name="docusaurus_version" content="current"><meta data-react-helmet="true" name="docusaurus_tag" content="docs-default-current"><meta data-react-helmet="true" property="og:title" content="Routing | Pistache"><meta data-react-helmet="true" name="description" content="&lt;!--"><meta data-react-helmet="true" property="og:description" content="&lt;!--"><link data-react-helmet="true" rel="shortcut icon" href="/img/logo.png"><link data-react-helmet="true" rel="canonical" href="https://pistache.io/docs/routing"><link data-react-helmet="true" rel="alternate" href="https://pistache.io/docs/routing" hreflang="en"><link data-react-helmet="true" rel="alternate" href="https://pistache.io/docs/routing" hreflang="x-default"><link rel="stylesheet" href="/assets/css/styles.35f9fda9.css">
<link rel="preload" href="/assets/js/runtime~main.53122274.js" as="script">
<link rel="preload" href="/assets/js/main.67d7f0b9.js" as="script">
<link rel="preload" href="/assets/js/main.0163458a.js" as="script">
</head>
<body>
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"light")}()</script><div id="__docusaurus">
<div><a href="#main" class="skipToContent_1oUP shadow--md">Skip to main content</a></div><nav class="navbar navbar--fixed-top"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Navigation bar toggle" class="navbar__toggle clean-btn" type="button" tabindex="0"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/"><img src="/img/logo.png" alt="Pistache logo" class="themedImage_1VuW themedImage--light_3UqQ navbar__logo"><img src="/img/logo.png" alt="Pistache logo" class="themedImage_1VuW themedImage--dark_hz6m navbar__logo"><b class="navbar__title">Pistache</b></a><a aria-current="page" class="navbar__item navbar__link navbar__link--active" href="/docs/">Docs</a></div><div class="navbar__items navbar__items--right"><a href="https://github.com/pistacheio/pistache" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link header-github-link" aria-label="GitHub repository"></a><div class="react-toggle displayOnlyInLargeViewport_GrZ2 react-toggle--disabled"><div class="react-toggle-track" role="button" tabindex="-1"><div class="react-toggle-track-check"><span class="toggle_71bT">🌜</span></div><div class="react-toggle-track-x"><span class="toggle_71bT">🌞</span></div><div class="react-toggle-thumb"></div></div><input type="checkbox" class="react-toggle-screenreader-only" aria-label="Switch between dark and light mode"></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div><div class="navbar-sidebar"><div class="navbar-sidebar__brand"><a class="navbar__brand" href="/"><img src="/img/logo.png" alt="Pistache logo" class="themedImage_1VuW themedImage--light_3UqQ navbar__logo"><img src="/img/logo.png" alt="Pistache logo" class="themedImage_1VuW themedImage--dark_hz6m navbar__logo"><b class="navbar__title">Pistache</b></a></div><div class="navbar-sidebar__items"><div class="menu"><ul class="menu__list"><li class="menu__list-item"><a aria-current="page" class="menu__link navbar__link--active" href="/docs/">Docs</a></li><li class="menu__list-item"><a href="https://github.com/pistacheio/pistache" target="_blank" rel="noopener noreferrer" class="menu__link header-github-link" aria-label="GitHub repository"></a></li></ul></div></div></div></nav><div class="main-wrapper docs-wrapper doc-page"><div class="docPage_31aa"><aside class="docSidebarContainer_3Kbt"><div class="sidebar_15mo"><nav class="menu menu--responsive thin-scrollbar menu_Bmed" aria-label="Sidebar navigation"><button aria-label="Open menu" aria-haspopup="true" class="button button--secondary button--sm menu__button" type="button"><svg class="sidebarMenuIcon_fgN0" width="24" height="24" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" href="/docs/asynchronous-http-programming">Asynchronous HTTP programming</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/headers">Headers</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/http-handler">HTTP handler</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/">Getting started</a></li><li class="menu__list-item"><a class="menu__link" href="/docs/rest-description">REST description</a></li><li class="menu__list-item"><a aria-current="page" class="menu__link menu__link--active active" href="/docs/routing">Routing</a></li></ul></nav></div></aside><main class="docMainContainer_3ufF"><div class="container padding-top--md padding-bottom--lg docItemWrapper_3FMP"><div class="row"><div class="col docItemCol_3FnS"><div class="docItemContainer_33ec"><article><div class="markdown"><header><h1 class="h1Heading_27L5">Routing</h1></header><p>HTTP routing consists of binding an HTTP route to a C++ callback. A special component called an HTTP router will be in charge of dispatching HTTP requests to the right C++ callback. A route is composed of an HTTP verb associated to a resource:</p><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly javascript"><pre tabindex="0" class="prism-code language-javascript codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token constant" style="color:rgb(130, 170, 255)">GET</span><span class="token plain"> </span><span class="token operator" style="color:rgb(137, 221, 255)">/</span><span class="token plain">users</span><span class="token operator" style="color:rgb(137, 221, 255)">/</span><span class="token number" style="color:rgb(247, 140, 108)">1</span></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><p>Here, <code>GET</code> is the verb and <code>/users/1</code> is the associated resource.</p><h2><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_2LWZ" id="http-methods"></a>HTTP methods<a class="hash-link" href="#http-methods" title="Direct link to heading">#</a></h2><p>A bunch of HTTP methods (verbs) are supported by Pistache:</p><ul><li><em>GET</em>: The <code>GET</code> method is used by the client (e.g browser) to retrieve a resource identified by an URI. For example, to retrieve an user identified by an id, a client will issue a <code>GET</code> to the <code>/users/:id</code> Request-URI.</li><li><em>POST</em>: the <code>POST</code> method is used to post or send new information to a certain resource. The server will then read and store the data associated to the request. <code>POST</code> is a common way of transmitting data from an HTML form. <code>POST</code> can also be used to create a new resource or update information of an existing resource. For example, to create a new user, a client will issue a <code>POST</code> to the <code>/users</code> path with the data of the user to create in its body.</li><li><em>PUT</em>: <code>PUT</code> is very similar to <code>POST</code> except that <code>PUT</code> is idempotent, meaning that two requests to the same Request-URI with the same identical content should have the same effect and should produce the same result.</li><li><em>DELETE</em>: the <code>DELETE</code> method is used to delete a resource associated to a given Request-URI. For example, to remove an user, a client might issue a <code>DELETE</code> call to the <code>/users/:id</code> Request-URI.</li></ul><p>To sum up, <code>POST</code> and <code>PUT</code> are used to Create and/or Update, <code>GET</code> is used to Read and <code>DELETE</code> is used to Delete information.</p><h2><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_2LWZ" id="route-patterns"></a>Route patterns<a class="hash-link" href="#route-patterns" title="Direct link to heading">#</a></h2><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_2LWZ" id="static-routes"></a>Static routes<a class="hash-link" href="#static-routes" title="Direct link to heading">#</a></h3><p>Static routes are the simplest ones as they do rely on dynamic parts of the Request-URI. For example <code>/users/all</code> is a static route that will exactly match the <code>/users/all</code> Request-URI.</p><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_2LWZ" id="dynamic-routes"></a>Dynamic routes<a class="hash-link" href="#dynamic-routes" title="Direct link to heading">#</a></h3><p>However, it is often useful to define routes that have dynamic parts. For example, to retrieve a specific user by its id, the id is needed to query the storage. Dynamic routes thus have parameters that are then matched one by one by the HTTP router. In a dynamic route, parameters are identified by a column <code>:</code></p><p><code>/users/:id</code></p><p>Here, <code>:id</code> is a dynamic parameter. When a request comes in, the router will try to match the <code>:id</code> parameter to the corresponding part of the request. For example, if the server receives a request to <code>/users/13</code>, the router will match the <code>13</code> value to the <code>:id</code> parameter.</p><p>Some parameters, like <code>:id</code> are named. However, Pistache also allows <em>splat</em> (wildcard) parameters, identified by a star <code>*</code>:</p><p><code>/link/*/to/*</code></p><h2><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_2LWZ" id="defining-routes"></a>Defining routes<a class="hash-link" href="#defining-routes" title="Direct link to heading">#</a></h2><p>To define your routes, you first have to instantiate an HTTP router:</p><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly cpp"><pre tabindex="0" class="prism-code language-cpp codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token plain">Http</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Router router</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><p>Then, use the <code>Routes::&lt;Method&gt;()</code> functions to add some routes:</p><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly cpp"><pre tabindex="0" class="prism-code language-cpp codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token class-name" style="color:rgb(255, 203, 107)">Routes</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token function" style="color:rgb(130, 170, 255)">Get</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">router</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token string" style="color:rgb(195, 232, 141)">&quot;/users/all&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 107)">Routes</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token function" style="color:rgb(130, 170, 255)">bind</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token operator" style="color:rgb(137, 221, 255)">&amp;</span><span class="token plain">UsersApi</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">getAllUsers</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token keyword" style="font-style:italic">this</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"></span><span class="token class-name" style="color:rgb(255, 203, 107)">Routes</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token function" style="color:rgb(130, 170, 255)">Post</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">router</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token string" style="color:rgb(195, 232, 141)">&quot;/users/:id&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 107)">Routes</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token function" style="color:rgb(130, 170, 255)">bind</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token operator" style="color:rgb(137, 221, 255)">&amp;</span><span class="token plain">UsersApi</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">getUserId</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token keyword" style="font-style:italic">this</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"></span><span class="token class-name" style="color:rgb(255, 203, 107)">Routes</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token function" style="color:rgb(130, 170, 255)">Get</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">router</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token string" style="color:rgb(195, 232, 141)">&quot;/link/*/to/*&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 107)">Routes</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token function" style="color:rgb(130, 170, 255)">bind</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token operator" style="color:rgb(137, 221, 255)">&amp;</span><span class="token plain">UsersApi</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">linkUsers</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token keyword" style="font-style:italic">this</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><p><code>Routes::bind</code> is a special function that will generate a corresponding C++ callback that will then be called by the router if a given route matches the Request-URI.</p><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_2LWZ" id="callbacks"></a>Callbacks<a class="hash-link" href="#callbacks" title="Direct link to heading">#</a></h3><p>A C++ callback associated to a route must have the following signature:</p><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly cpp"><pre tabindex="0" class="prism-code language-cpp codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token keyword" style="font-style:italic">void</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token keyword" style="font-style:italic">const</span><span class="token plain"> Rest</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Request</span><span class="token operator" style="color:rgb(137, 221, 255)">&amp;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> Http</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">ResponseWriter</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><p>A callback can either be a non-static free or member function. For member functions, a pointer to the corresponding instance must be passed to the Routes::bind function so that the router knows on which instance to invoke the member function.</p><p>The first parameter of the callback is <code>Rest::Request</code> and not an <code>Http::Request</code>. A <code>Rest::Request</code> is an <code>Http::Request</code> with additional functions. Named and splat parameters are for example retrieved through this object:</p><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly cpp"><pre tabindex="0" class="prism-code language-cpp codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token keyword" style="font-style:italic">void</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 107)">UsersApi</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token function" style="color:rgb(130, 170, 255)">getUserId</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token keyword" style="font-style:italic">const</span><span class="token plain"> Rest</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Request</span><span class="token operator" style="color:rgb(137, 221, 255)">&amp;</span><span class="token plain"> request</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> Http</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">ResponseWriter response</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token keyword" style="font-style:italic">auto</span><span class="token plain"> id </span><span class="token operator" style="color:rgb(137, 221, 255)">=</span><span class="token plain"> request</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">param</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(195, 232, 141)">&quot;:id&quot;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">as</span><span class="token operator" style="color:rgb(137, 221, 255)">&lt;</span><span class="token keyword" style="font-style:italic">int</span><span class="token operator" style="color:rgb(137, 221, 255)">&gt;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token comment" style="color:rgb(105, 112, 152);font-style:italic">// ...</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain" style="display:inline-block">
</span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"></span><span class="token keyword" style="font-style:italic">void</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 107)">UsersApi</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token function" style="color:rgb(130, 170, 255)">linkUsers</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token keyword" style="font-style:italic">const</span><span class="token plain"> Rest</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">Request</span><span class="token operator" style="color:rgb(137, 221, 255)">&amp;</span><span class="token plain"> request</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> Http</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">ResponseWriter response</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token keyword" style="font-style:italic">auto</span><span class="token plain"> u1 </span><span class="token operator" style="color:rgb(137, 221, 255)">=</span><span class="token plain"> request</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">splatAt</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token number" style="color:rgb(247, 140, 108)">0</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">as</span><span class="token operator" style="color:rgb(137, 221, 255)">&lt;</span><span class="token plain">std</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">string</span><span class="token operator" style="color:rgb(137, 221, 255)">&gt;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token keyword" style="font-style:italic">auto</span><span class="token plain"> u2 </span><span class="token operator" style="color:rgb(137, 221, 255)">=</span><span class="token plain"> request</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">splatAt</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token number" style="color:rgb(247, 140, 108)">1</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">as</span><span class="token operator" style="color:rgb(137, 221, 255)">&lt;</span><span class="token plain">std</span><span class="token operator" style="color:rgb(137, 221, 255)">::</span><span class="token plain">string</span><span class="token operator" style="color:rgb(137, 221, 255)">&gt;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"> </span><span class="token comment" style="color:rgb(105, 112, 152);font-style:italic">// ...</span><span class="token plain"></span></span><span class="token-line" style="color:#bfc7d5"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div><p>As you can see, parameters are also typed. To cast a parameter to the appropriate type, use the <code>as&lt;T&gt;</code> member template.</p><div class="admonition admonition-note alert alert--secondary"><div class="admonition-heading"><h5><span class="admonition-icon"><svg xmlns="http://www.w3.org/2000/svg" width="14" height="16" viewBox="0 0 14 16"><path fill-rule="evenodd" d="M6.3 5.69a.942.942 0 0 1-.28-.7c0-.28.09-.52.28-.7.19-.18.42-.28.7-.28.28 0 .52.09.7.28.18.19.28.42.28.7 0 .28-.09.52-.28.7a1 1 0 0 1-.7.3c-.28 0-.52-.11-.7-.3zM8 7.99c-.02-.25-.11-.48-.31-.69-.2-.19-.42-.3-.69-.31H6c-.27.02-.48.13-.69.31-.2.2-.3.44-.31.69h1v3c.02.27.11.5.31.69.2.2.42.31.69.31h1c.27 0 .48-.11.69-.31.2-.19.3-.42.31-.69H8V7.98v.01zM7 2.3c-3.14 0-5.7 2.54-5.7 5.68 0 3.14 2.56 5.7 5.7 5.7s5.7-2.55 5.7-5.7c0-3.15-2.56-5.69-5.7-5.69v.01zM7 .98c3.86 0 7 3.14 7 7s-3.14 7-7 7-7-3.12-7-7 3.14-7 7-7z"></path></svg></span>Cast safety</h5></div><div class="admonition-content"><p>An exception will be thrown if the parameter can not be casted to the right type</p></div></div><h3><a aria-hidden="true" tabindex="-1" class="anchor enhancedAnchor_2LWZ" id="installing-the-handler"></a>Installing the handler<a class="hash-link" href="#installing-the-handler" title="Direct link to heading">#</a></h3><p>Once the routes have been defined, the final <code>Http::Handler</code> must be set to the HTTP Endpoint. To retrieve the handler, just call the <code>handler()</code> member function on the router object:</p><div class="codeBlockContainer_K1bP"><div class="codeBlockContent_hGly cpp"><pre tabindex="0" class="prism-code language-cpp codeBlock_23N8 thin-scrollbar" style="color:#bfc7d5;background-color:#292d3e"><code class="codeBlockLines_39YC"><span class="token-line" style="color:#bfc7d5"><span class="token plain">endpoint</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">setHandler</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">router</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">handler</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span></span></code></pre><button type="button" aria-label="Copy code to clipboard" class="copyButton_Ue-o clean-btn">Copy</button></div></div></div><footer class="row docusaurus-mt-lg"><div class="col"><a href="https://github.com/pistacheio/pistache/edit/master/pistache.io/docs/routing.md" target="_blank" rel="noreferrer noopener"><svg fill="currentColor" height="20" width="20" viewBox="0 0 40 40" class="iconEdit_2_ui" aria-hidden="true"><g><path d="m34.5 11.7l-3 3.1-6.3-6.3 3.1-3q0.5-0.5 1.2-0.5t1.1 0.5l3.9 3.9q0.5 0.4 0.5 1.1t-0.5 1.2z m-29.5 17.1l18.4-18.5 6.3 6.3-18.4 18.4h-6.3v-6.2z"></path></g></svg>Edit this page</a></div><div class="col lastUpdated_3DPF"></div></footer></article><nav class="pagination-nav docusaurus-mt-lg" aria-label="Docs pages navigation"><div class="pagination-nav__item"><a class="pagination-nav__link" href="/docs/rest-description"><div class="pagination-nav__sublabel">Previous</div><div class="pagination-nav__label">« REST description</div></a></div><div class="pagination-nav__item pagination-nav__item--next"></div></nav></div></div><div class="col col--3"><div class="tableOfContents_35-E thin-scrollbar"><ul class="table-of-contents table-of-contents__left-border"><li><a href="#http-methods" class="table-of-contents__link">HTTP methods</a></li><li><a href="#route-patterns" class="table-of-contents__link">Route patterns</a><ul><li><a href="#static-routes" class="table-of-contents__link">Static routes</a></li><li><a href="#dynamic-routes" class="table-of-contents__link">Dynamic routes</a></li></ul></li><li><a href="#defining-routes" class="table-of-contents__link">Defining routes</a><ul><li><a href="#callbacks" class="table-of-contents__link">Callbacks</a></li><li><a href="#installing-the-handler" class="table-of-contents__link">Installing the handler</a></li></ul></li></ul></div></div></div></div></main></div></div><footer class="footer footer--dark"><div class="container"><div class="row footer__links"><div class="col footer__col"><div class="footer__title">Docs</div><ul class="footer__items"><li class="footer__item"><a class="footer__link-item" href="/docs/">Quickstart</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/http-handler/">User guide</a></li></ul></div><div class="col footer__col"><div class="footer__title">Community</div><ul class="footer__items"><li class="footer__item"><a href="https://stackoverflow.com/questions/tagged/pistache" target="_blank" rel="noopener noreferrer" class="footer__link-item">Stack Overflow</a></li><li class="footer__item"><a href="https://web.libera.chat/#pistache" target="_blank" rel="noopener noreferrer" class="footer__link-item">#pistache on Libera.Chat</a></li></ul></div><div class="col footer__col"><div class="footer__title">More</div><ul class="footer__items"><li class="footer__item"><a href="https://github.com/pistacheio/pistache" target="_blank" rel="noopener noreferrer" class="footer__link-item">GitHub</a></li></ul></div></div><div class="footer__bottom text--center"><div class="footer__copyright">Pistache, 2015 - 2021</div></div></div></footer></div>
<script src="/assets/js/runtime~main.53122274.js"></script>
<script src="/assets/js/main.67d7f0b9.js"></script>
<script src="/assets/js/main.0163458a.js"></script>
</body>
</html>
\ No newline at end of file
......@@ -6,12 +6,12 @@
<meta name="generator" content="Docusaurus v2.0.0-beta.1">
<title data-react-helmet="true">Pistache</title><meta data-react-helmet="true" property="og:title" content="Pistache"><meta data-react-helmet="true" property="og:url" content="https://pistache.io/"><meta data-react-helmet="true" name="docusaurus_locale" content="en"><meta data-react-helmet="true" name="docusaurus_tag" content="default"><link data-react-helmet="true" rel="shortcut icon" href="/img/logo.png"><link data-react-helmet="true" rel="canonical" href="https://pistache.io/"><link data-react-helmet="true" rel="alternate" href="https://pistache.io/" hreflang="en"><link data-react-helmet="true" rel="alternate" href="https://pistache.io/" hreflang="x-default"><script data-react-helmet="true">function maybeInsertBanner(){window.__DOCUSAURUS_INSERT_BASEURL_BANNER&&insertBanner()}function insertBanner(){var n=document.getElementById("docusaurus-base-url-issue-banner-container");if(n){n.innerHTML='\n<div id="docusaurus-base-url-issue-banner" style="border: thick solid red; background-color: rgb(255, 230, 179); margin: 20px; padding: 20px; font-size: 20px;">\n <p style="font-weight: bold; font-size: 30px;">Your Docusaurus site did not load properly.</p>\n <p>A very common reason is a wrong site <a href="https://docusaurus.io/docs/docusaurus.config.js/#baseurl" style="font-weight: bold;">baseUrl configuration</a>.</p>\n <p>Current configured baseUrl = <span style="font-weight: bold; color: red;">/</span> (default value)</p>\n <p>We suggest trying baseUrl = <span id="docusaurus-base-url-issue-banner-suggestion-container" style="font-weight: bold; color: green;"></span></p>\n</div>\n';var e=document.getElementById("docusaurus-base-url-issue-banner-suggestion-container"),s=window.location.pathname,r="/"===s.substr(-1)?s:s+"/";e.innerHTML=r}}window.__DOCUSAURUS_INSERT_BASEURL_BANNER=!0,document.addEventListener("DOMContentLoaded",maybeInsertBanner)</script><link rel="stylesheet" href="/assets/css/styles.35f9fda9.css">
<link rel="preload" href="/assets/js/runtime~main.53122274.js" as="script">
<link rel="preload" href="/assets/js/main.67d7f0b9.js" as="script">
<link rel="preload" href="/assets/js/main.0163458a.js" as="script">
</head>
<body>
<script>!function(){function t(t){document.documentElement.setAttribute("data-theme",t)}var e=function(){var t=null;try{t=localStorage.getItem("theme")}catch(t){}return t}();t(null!==e?e:"light")}()</script><div id="__docusaurus">
<div id="docusaurus-base-url-issue-banner-container"></div><div><a href="#main" class="skipToContent_1oUP shadow--md">Skip to main content</a></div><nav class="navbar navbar--fixed-top"><div class="navbar__inner"><div class="navbar__items"><button aria-label="Navigation bar toggle" class="navbar__toggle clean-btn" type="button" tabindex="0"><svg width="30" height="30" viewBox="0 0 30 30" aria-hidden="true"><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></button><a class="navbar__brand" href="/"><img src="/img/logo.png" alt="Pistache logo" class="themedImage_1VuW themedImage--light_3UqQ navbar__logo"><img src="/img/logo.png" alt="Pistache logo" class="themedImage_1VuW themedImage--dark_hz6m navbar__logo"><b class="navbar__title">Pistache</b></a><a class="navbar__item navbar__link" href="/docs/">Docs</a></div><div class="navbar__items navbar__items--right"><a href="https://github.com/pistacheio/pistache" target="_blank" rel="noopener noreferrer" class="navbar__item navbar__link header-github-link" aria-label="GitHub repository"></a><div class="react-toggle displayOnlyInLargeViewport_GrZ2 react-toggle--disabled"><div class="react-toggle-track" role="button" tabindex="-1"><div class="react-toggle-track-check"><span class="toggle_71bT">🌜</span></div><div class="react-toggle-track-x"><span class="toggle_71bT">🌞</span></div><div class="react-toggle-thumb"></div></div><input type="checkbox" class="react-toggle-screenreader-only" aria-label="Switch between dark and light mode"></div></div></div><div role="presentation" class="navbar-sidebar__backdrop"></div><div class="navbar-sidebar"><div class="navbar-sidebar__brand"><a class="navbar__brand" href="/"><img src="/img/logo.png" alt="Pistache logo" class="themedImage_1VuW themedImage--light_3UqQ navbar__logo"><img src="/img/logo.png" alt="Pistache logo" class="themedImage_1VuW themedImage--dark_hz6m navbar__logo"><b class="navbar__title">Pistache</b></a></div><div class="navbar-sidebar__items"><div class="menu"><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" href="/docs/">Docs</a></li><li class="menu__list-item"><a href="https://github.com/pistacheio/pistache" target="_blank" rel="noopener noreferrer" class="menu__link header-github-link" aria-label="GitHub repository"></a></li></ul></div></div></div></nav><div class="main-wrapper"><header class="hero hero--primary heroBanner_1ZBZ"><div class="container"><h1 class="hero__title">Pistache</h1><p class="hero__subtitle">An elegant C++ REST framework.</p><div class="buttons_irzW"><a class="button button--outline button--secondary button--lg" href="/docs/">Get Started</a></div></div></header><main><section class="features_pzNA"><div class="container"><div class="row"><div class="col col--4"><div class="text--center"><svg data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" width="897" height="697.835" viewBox="0 0 897 697.835" class="featureSvg_3LcT" alt="Modern API"><defs><linearGradient id="undraw_futuristic_interface_svg__a" x1="369" y1="646" x2="369" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="#e4e4e4"></stop><stop offset="0.473" stop-color="#f0f0f0" stop-opacity="0.7"></stop></linearGradient></defs><path opacity="0.4" fill="url(#undraw_futuristic_interface_svg__a)" d="M369 646L706.75 0H31.25L369 646 706.75 0H31.25L369 646z"></path><path fill="#3f3d56" d="M323 571h92v92h-92zM374 368c-95.944 0-174-78.056-174-174S278.056 20 374 20s174 78.056 174 174-78.056 174-174 174zm0-343c-93.187 0-169 75.813-169 169s75.813 169 169 169 169-75.813 169-169S467.187 25 374 25z"></path><path d="M374 326c-72.785 0-132-59.215-132-132S301.215 62 374 62s132 59.215 132 132-59.215 132-132 132zm0-261a129 129 0 10129 129A129.146 129.146 0 00374 65z" fill="#3f3d56"></path><path d="M374 236a42 42 0 1142-42 42.048 42.048 0 01-42 42zm0-82a40 40 0 1040 40 40.045 40.045 0 00-40-40z" fill="#3f3d56"></path><path d="M364 144a41 41 0 00-41 41h41z" fill="#b6ce5d"></path><path d="M323 203a41 41 0 0041 41v-41zM381 144v41h41a41 41 0 00-41-41z" fill="#b6ce5d" opacity="0.3"></path><path d="M381 240a41 41 0 0041-41h-41z" fill="#b6ce5d"></path><path fill="#3f3d56" d="M415.406 144.923l-1.812-.846L434.863 98.5H572.5v2H436.137l-20.731 44.423zM528 55h78v6h-78zM528 68h78v6h-78zM528 81h78v6h-78zM335 385h78v6h-78zM335 398h78v6h-78zM335 411h78v6h-78zM446 428h-2V272.286l-22.85-36.758 1.7-1.056L446 271.714V428zM304 428h-2V271.714l23.151-37.242 1.698 1.056L304 272.286V428z"></path><path fill="#2f2e41" d="M0 662h897v2H0z"></path><ellipse cx="689.863" cy="456.192" rx="61.548" ry="15.572" fill="#2f2e41"></ellipse><path d="M665.763 248.932s-.741 29.661-6.673 33.369 10.381 14.83 10.381 14.83l24.47-4.449 15.573-19.28s-11.123-13.347-7.415-24.47z" fill="#ffb6b6"></path><path d="M665.763 248.932s-.741 29.661-6.673 33.369 10.381 14.83 10.381 14.83l24.47-4.449 15.573-19.28s-11.123-13.347-7.415-24.47z" opacity="0.1"></path><path d="M632.394 277.852s-12.606 5.19-13.347 22.987 0 69.705 0 69.705l21.504-1.483z" fill="#f0f0f0"></path><path fill="#2f2e41" d="M725.835 464.818l1.47-.197L754 663.724l-1.47.197zM701.36 467.75l1.478-.129 17.055 196.507-1.478.129zM635.417 663.76l20.656-226.55 1.477.134-20.656 226.55zM673.771 433.552l1.482-.053 8.307 231.038-1.482.054z"></path><path d="M611.631 403.172s-85.277 5.932-71.188 34.11 82.311 75.637 82.311 75.637 12.606 2.966 14.831 3.708 36.335-22.246 36.335-22.246-20.763-12.606-30.403-14.83-37.077-25.955-37.077-25.955l77.12-19.28-45.233-38.56z" fill="#2f2e41"></path><path d="M679.853 421.71s-48.942 69.233-39.302 96.535 2.966 117.77 2.966 117.77 36.336 11.864 36.336 0 10.381-95.659 0-123.837c0 0 2.224-17.797 8.157-20.763s26.695-30.403 26.695-30.403 22.246-10.382 19.28-20.022-54.132-19.28-54.132-19.28z" fill="#2f2e41"></path><path d="M713.963 233.36a29.662 29.662 0 11-29.661-29.662 29.649 29.649 0 0129.661 29.661z" fill="#ffb6b6"></path><path d="M703.582 263.02s44.492 18.54 37.818 42.269-20.763 126.061-42.267 126.061-66.739-11.865-69.705-16.314 11.123-94.917 11.123-94.917 17.038-55.158 23.35-50.567c0 0-4.07 23.872 17.435 17.94s22.246-24.471 22.246-24.471z" fill="#f0f0f0"></path><path d="M664.787 263.02s-37.584 5.192-36.1 13.349l-2.967 31.144 11.865 63.03-1.483 20.764-36.335 12.606 43.009 12.606s17.797-85.277 14.83-101.59 7.181-51.908 7.181-51.908zM702.43 260.394s40.453 23.39 43.42 30.805 0 78.603 0 78.603 5.19 66.739-9.64 83.794c0 0 5.19-8.898-22.247-8.898s-40.784-5.19-41.526-5.932-14.83 0-14.83 0-5.191-106.04 11.864-125.32 35.515-41.589 32.959-53.052z" fill="#3f3d56"></path><path d="M623.496 416.52v8.898s-29.662 27.437-17.797 34.852 34.852-26.695 34.852-26.695l2.794-19.82z" fill="#ffb6b6"></path><path d="M623.496 416.52v8.898s-29.662 27.437-17.797 34.852 34.852-26.695 34.852-26.695l2.794-19.82z" opacity="0.1"></path><path d="M635.36 510.695l8.157 11.864s-28.178 43.01-15.572 47.459 67.48-48.942 66.738-53.391-26.695-22.246-26.695-22.246zM645.742 630.082l-6.674 29.662s-25.954 34.11-14.09 37.077 38.56-.742 42.269-8.899 8.156-19.28 14.089-28.178-5.191-29.662-5.191-29.662z" fill="#2f2e41"></path><path d="M624.237 357.196l-5.19 13.348 2.224 51.166s18.539-7.415 24.47 0l-5.19-51.166-8.157-13.348z" fill="#f0f0f0"></path><path d="M651.674 421.71l-14.089 4.45s-54.874 17.796-30.403 30.402 38.56-8.157 38.56-8.157l9.64-7.415z" fill="#ffb6b6"></path><path d="M734.727 293.424s-20.022 9.64-22.988 35.594-6.674 60.064-6.674 60.064l-37.077 24.471s-25.356-1.006-21.576 8.396 4.52 29.423 11.195 26.456 16.313-20.763 25.953-21.504 49.683-16.314 54.133-34.11 21.504-77.862 14.089-86.76-11.123-16.315-17.055-12.607z" fill="#f0f0f0"></path><path d="M656.23 214.452s-11.868-.18-14.455 4.404-1.738 7.908 1.77 7.991 19.843-9.54 19.843-9.54z" fill="#3f3d56"></path><path d="M656.23 214.452s-11.868-.18-14.455 4.404-1.738 7.908 1.77 7.991 19.843-9.54 19.843-9.54z" opacity="0.1"></path><path d="M708.105 229.627l-8.117 7.033s-7.707 7.146-18.8-3.855-26.784-19.739-33.247-17.105l16.477-6.937 16.012-.444 18.193 7.661z" fill="#3f3d56"></path><path d="M713.646 237.554a101.032 101.032 0 00-10.186-9.988c-6.996-6.006-16.887-12.946-27.407-15.376 0 0-10.553-3.35-18.063-.122l14.522-15.861s7.85-4.459 11.952-3.328c0 0 13.8 2.968 17.705 6.436.11.096.211.195.304.29a10.1 10.1 0 016.15 3.333c3.554 4.06 9.144 12.017 7.932 20.852-1.75 12.76-2.91 13.764-2.91 13.764z" fill="#3f3d56"></path><path d="M706.182 231.447c-29.895-25.19-46.887-19.712-47.055-19.653l-.491-1.4c.714-.252 17.867-5.895 48.502 19.92z" opacity="0.1"></path><ellipse cx="853.228" cy="299.96" rx="2.966" ry="4.449" transform="rotate(-60 689.938 380.622)" fill="#3f3d56"></ellipse><ellipse cx="860.643" cy="334.812" rx="2.225" ry="3.708" transform="rotate(-8.311 89.263 1326.867)" fill="#ffb6b6"></ellipse><path d="M683.79 253.766c2.84-4.745-1.535-6.785-1.535-6.785s-10.01-3.648-13.733-5.012c-3.73-1.357-5.465 4.011-5.465 4.011-.675.32-4.739-2.78-7.594-5.658a29.673 29.673 0 0044.24 18.39l5.25-12.687c-7.245 4.833-14.306 7.484-21.163 7.741zm-4.545 1.788a7.31 7.31 0 01-6.926 1.92l.23-1.246s4.3-.215 2.484-1.32a33.998 33.998 0 00-6.281-2.291s-1.372-.497.015 1.787l.77.95-.555.904s-4.034-2.358-3.656-6.444c0 0-.423-3.715 4.479-1.928 4.909 1.795 8.446 3.077 8.446 3.077s4.115 1.506.994 4.59z" fill="#3f3d56"></path></svg></div><h3>Modern API</h3><p>Written in pure C++17 and providing a low-level HTTP abstraction, Pistache makes playing with its modern API fun and easy, just take a look at the quickstart</p></div><div class="col col--4"><div class="text--center"><svg data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" width="688.134" height="510.5" viewBox="0 0 688.134 510.5" class="featureSvg_3LcT" alt="What&#x27;s in the box"><path d="M647.354 460.681a24.146 24.146 0 000 48.291 24.146 24.146 0 000-48.29z" fill="#ccc"></path><path data-name="Path 395" d="M645.063 494.855a2.93 2.93 0 01-1.763-.586l-.031-.024-6.64-5.08a2.95 2.95 0 113.59-4.683l4.301 3.298 10.164-13.259a2.95 2.95 0 014.135-.546l-.062.088.065-.088a2.953 2.953 0 01.545 4.137L647.413 493.7a2.951 2.951 0 01-2.347 1.151z" fill="#fff"></path><path fill="#ffb8b8" d="M594.783 499.316l-11.432-.001-5.436-44.096 16.872.002-.004 44.095z"></path><path d="M575.185 496.048h22.048v13.882h-35.93a13.882 13.882 0 0113.882-13.882z" fill="#2f2e41"></path><path fill="#ffb8b8" d="M549.283 499.316l-11.432-.001-5.436-44.096 16.872.002-.004 44.095z"></path><path d="M529.685 496.048h22.048v13.882h-35.93a13.882 13.882 0 0113.882-13.882z" fill="#2f2e41"></path><path d="M603.59 346.866a9.377 9.377 0 011.976-14.242l-3.54-21.134 12.317-5.284 4.581 29.915a9.428 9.428 0 01-15.334 10.745zM507.152 336.88a9.377 9.377 0 00.404-14.373l6.983-20.258-11.275-7.246-9.46 28.747a9.428 9.428 0 0013.348 13.13z" fill="#ffb8b8"></path><circle cx="565.702" cy="163.08" r="24.561" fill="#ffb8b8"></circle><path d="M506.393 321.724a4.502 4.502 0 01-1.246-.176l-7.158-2.055a4.508 4.508 0 01-3.088-5.552l14.774-52.162 20.602-50.575c2.048-5.028 6.328-8.325 11.17-8.605a11.446 11.446 0 0110.778 6.277 15.62 15.62 0 01.357 13.77l-23.417 51.21-18.617 45.084a4.498 4.498 0 01-4.155 2.784z" fill="#b6ce5d"></path><path d="M579.562 183.677l-13.646.243a9.074 9.074 0 01-8.896-11.59 21.127 21.127 0 00.655-3.013 15.225 15.225 0 00.09-3.353 4.952 4.952 0 00-9.554-1.409c-2.295.033-7.183-.715-9.478-.682-4.872-12.49 5.745-28.834 17.174-34.972 11.651-6.258 26.775.108 31.241 13.151 6.199.112 11.235 6.225 12.034 13.107s-2.032 14.067-6.363 19.342-10.018 9.118-13.257 9.176zM534.704 495.2a4.515 4.515 0 01-4.461-4.01l-5.064-170.236 63.788 4.54.049.41c14.415 120.663 9.487 162.432 9.436 162.84a4.498 4.498 0 01-5.076 4.203l-14.096.338a4.498 4.498 0 01-3.99-4.296l-13.17-123.3a1.406 1.406 0 00-1.467-1.056 1.463 1.463 0 00-1.44 1.177l-5.088 123.704a4.48 4.48 0 01-4.041 4.67l-14.932.993a4.459 4.459 0 01-.448.022z" fill="#2f2e41"></path><path d="M561.173 341.295c-.382 0-.763-.006-1.145-.018-18.342-.552-32.692-14.429-36.653-18.67a4.478 4.478 0 01-1.081-4.096l10.581-44.764-2.807-38.917a38.37 38.37 0 0110.506-29.634 31.663 31.663 0 0124.386-9.865c17.855.852 31.941 16.811 32.069 36.332.197 30.235-.693 32.312-.985 32.995-8.911 20.797-4.044 49.989-2.34 58.441a4.516 4.516 0 01-1.338 4.188c-9.8 9.298-20.29 14.007-31.193 14.008z" fill="#b6ce5d"></path><path d="M607.238 329.916a4.497 4.497 0 01-4.38-3.494l-10.918-47.557-14.63-54.358a15.621 15.621 0 012.627-13.522 11.456 11.456 0 0111.667-4.41c4.728 1.076 8.405 5.035 9.595 10.332l11.954 53.23 5.963 53.94a4.509 4.509 0 01-3.963 4.965l-7.4.844a4.487 4.487 0 01-.515.03z" fill="#b6ce5d"></path><path d="M293 52H26a26 26 0 010-52h267a26 26 0 010 52z" fill="#e6e6e6"></path><path d="M26 8.5a17.5 17.5 0 000 35h267a17.5 17.5 0 000-35z" fill="#fff"></path><path d="M387.354 1.681a24.146 24.146 0 000 48.291 24.146 24.146 0 000-48.29z" fill="#b6ce5d"></path><path data-name="Path 395" d="M385.063 35.855a2.93 2.93 0 01-1.763-.586l-.031-.024-6.64-5.08a2.95 2.95 0 113.59-4.683l4.301 3.298 10.164-13.259a2.95 2.95 0 014.135-.546l-.062.088.065-.088a2.953 2.953 0 01.545 4.137L387.413 34.7a2.951 2.951 0 01-2.347 1.151z" fill="#fff"></path><path d="M293 140H26a26 26 0 010-52h267a26 26 0 010 52z" fill="#e6e6e6"></path><path d="M26 96.5a17.5 17.5 0 000 35h267a17.5 17.5 0 000-35z" fill="#fff"></path><path d="M387.354 89.681a24.146 24.146 0 000 48.291 24.146 24.146 0 000-48.29z" fill="#b6ce5d"></path><path data-name="Path 395" d="M385.063 123.855a2.93 2.93 0 01-1.763-.586l-.031-.024-6.64-5.08a2.95 2.95 0 113.59-4.683l4.301 3.298 10.164-13.259a2.95 2.95 0 014.135-.546l-.062.088.065-.088a2.953 2.953 0 01.545 4.137L387.413 122.7a2.951 2.951 0 01-2.347 1.151z" fill="#fff"></path><path d="M293 228H26a26 26 0 010-52h267a26 26 0 010 52z" fill="#e6e6e6"></path><path d="M26 184.5a17.5 17.5 0 000 35h267a17.5 17.5 0 000-35z" fill="#fff"></path><path d="M387.354 177.681a24.146 24.146 0 000 48.291 24.146 24.146 0 000-48.29z" fill="#e6e6e6"></path><path d="M687.134 510.5h-209a1 1 0 010-2h209a1 1 0 010 2z" fill="#ccc"></path></svg></div><h3>What&#x27;s in the box</h3><p></p><ul><li>A multi-threaded HTTP server to build your APIs</li><li>An asynchronous HTTP client to request APIs</li><li>An HTTP router to dispatch requests to C++ functions</li><li>A REST description DSL to easily define your APIs</li><li>Type-safe headers and MIME types implementation</li></ul><p></p></div><div class="col col--4"><div class="text--center"><svg data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" width="1038.23" height="693.31" viewBox="0 0 1038.23 693.31" class="featureSvg_3LcT" alt="Use it"><defs><linearGradient id="undraw_version_control_svg__a" x1="320.96" y1="796.01" x2="320.96" y2="284.81" gradientUnits="userSpaceOnUse"><stop offset="0" stop-color="gray" stop-opacity="0.25"></stop><stop offset="0.54" stop-color="gray" stop-opacity="0.12"></stop><stop offset="1" stop-color="gray" stop-opacity="0.1"></stop></linearGradient></defs><path d="M615.24 111.4c-64.72-2.25-126.36-23.14-185.23-46S312.85 17.21 249.68 5.1c-40.63-7.79-87.09-8.89-119.83 12.89-31.5 21-41.68 57.15-47.16 90.72-4.11 25.27-6.54 51.85 4.75 75.5 7.83 16.42 21.74 30.22 31.36 45.95 33.46 54.72 9.81 122.2-26.46 175.63-17 25.06-36.74 49-49.87 75.66s-19.2 57.25-7.72 84.47c11.39 27 38.52 47.24 67.9 61.49 59.69 28.94 130 37.23 198.62 41.92 151.82 10.39 304.46 5.89 456.68 1.39 56.34-1.67 112.92-3.36 168.34-12.07 30.78-4.84 62.56-12.52 84.9-31 28.36-23.53 35.39-63.38 16.39-92.88-31.88-49.49-120-61.79-142.31-114.9-12.27-29.23.33-61.8 18.15-88.91 38.24-58.17 102.33-109.19 105.71-175.68 2.32-45.66-28.49-91.39-76.13-113-49.94-22.65-119.18-19.8-156 17.69-37.96 38.56-104.62 53.41-161.76 51.43z" fill="#b6ce5d" opacity="0.1"></path><path d="M529.62 754.84c-1-3.62-2-7.28-4-10.43a36.53 36.53 0 00-6.55-7.17c-7.25-6.58-16.15-13.26-25.76-11.6a34.39 34.39 0 00-8.54 3.12c-1.4.65-2.81 1.3-4.25 1.85a21.17 21.17 0 01-12.82 1.12c-2.2-.59-4.25-1.65-6.42-2.31a20.35 20.35 0 00-3.15-.68 53.64 53.64 0 006.09-3.21c10.78-6.6 19.38-18.53 18.18-31.29-.41-4.29-1.88-8.4-3.34-12.45l-3.84-10.62c-1.66-4.6-3.38-9.29-6.41-13.11-3.37-4.26-8.17-7.15-13.13-9.3-10.65-4.63-22.29-6.26-33.78-7.84l-.8-.11V516.68a8 8 0 00-8-8H398q-1-6.12-2-12.22c-1.9-11.61-3.87-23.43-9.22-33.88-3.5-6.84-9.07-13.37-16.58-14.71a16.08 16.08 0 01-4.31-1c-2.2-1.08-3.4-3.48-5.09-5.25-4.36-4.57-11.45-4.64-17.29-7-5.16-2.05-9.38-5.91-14.08-8.88s-10.54-5.08-15.74-3.15c0 .38-.07.76-.11 1.13l-3.34-1.54c-3.6-1.67-7.27-3.38-10.16-6.12-3.71-3.5-5.69-8.14-7.23-13.07-.16-.51-.31-1-.47-1.55a46.43 46.43 0 0012.44-23.75l.81 2.63a17.45 17.45 0 00.64 1.74 6.86 6.86 0 002 2.83 3.55 3.55 0 00.84.49 3.5 3.5 0 00.86.22 3.2 3.2 0 001.24-.09 4.73 4.73 0 003-2.78 6 6 0 00.35-1.22 6.31 6.31 0 00.07-.76v-.24-.52-.28c0-.1 0-.33-.05-.5v-.26c0-.2-.06-.4-.1-.59s0-.11 0-.16c-.05-.25-.11-.51-.16-.76v-.19c0-.06-.09-.41-.14-.62s-.07-.27-.1-.41v-.06c-.1-.4-.19-.79-.28-1.19a34.38 34.38 0 01-.55-10.56 113.08 113.08 0 012.86-15.35l.21-.91c.08-.35.16-.7.23-1.06.16-.72.32-1.44.47-2.17l.36-1.84.27-1.64v-.21A47.41 47.41 0 00318 330c-.46-5.23-2.08-10.18-5.63-14.12-2.51-2.79-5.82-4.85-8.15-7.78-2.18-2.74-3.41-6.12-5.67-8.81-6.24-7.45-22.26-13.19-32.09-14.19-11.26-1.14-29.45 1.74-38.53 8.39-3.36 2.45-5.66 6-8 9.36-4.3 6.25-9.18 12.49-16.07 16-2.6 1.32-5.58 2.32-7.31 4.62a12.49 12.49 0 00-1.95 5.18 102.71 102.71 0 00-2.06 19.78v2.5a18.23 18.23 0 001.56 7.23c.16.34.34.67.53 1l.12.21a39.78 39.78 0 013.2 5.45 7.22 7.22 0 01.49 1.66 12.24 12.24 0 01-.28 4.38c0 .22-.09.44-.13.66l-.09.43c0 .15 0 .3-.08.44-.08.43-.15.86-.21 1.28a9 9 0 00.22 3.46 4.55 4.55 0 002.22 3 6.5 6.5 0 001.8.56c.63.11 1.27.18 1.89.32a9.33 9.33 0 012.29.85 9.22 9.22 0 011.93 1.24 11 11 0 01.83.84 14 14 0 011.42 1.94q.32.53.6 1.08a24.67 24.67 0 011.71 4.52c.26.93.48 1.87.67 2.81.09.42.17.84.24 1.25s.14.83.2 1.24a2.91 2.91 0 00.8-.16c1.47-.53 2.29-2.24 2.75-3.9.08-.28.15-.55.21-.82.23-1 .47-2.1.7-3.15a46.37 46.37 0 0018.25 20.1c.28.83.55 1.65.79 2.49 1.31 4.53 1.94 9.27-.33 13.23-1.62 2.81-4.34 4.54-7.38 5.74a4.88 4.88 0 00-1.65-1.4c-2.63-1.32-5.79.28-8 2.25-4 3.62-7.26 8.81-12.52 10-1.9.44-4 .35-5.58 1.51a13 13 0 00-2.59 3.4 11.92 11.92 0 01-10.23 5.1c-1.83-.09-4-.51-5.25.83-.93 1-1 2.58-2 3.53-1.34 1.32-3.54.68-5.41.6-3.56-.15-6.87 2.15-8.9 5.1s-3 6.48-4 10v.06a7.15 7.15 0 00-.73.61 10.55 10.55 0 00-2.21 3.58 170.87 170.87 0 00-14.1 58.18 6 6 0 01-.64 2.82 13.87 13.87 0 01-1.47 1.6 5.61 5.61 0 00.93 8 6.3 6.3 0 011.07-1.42c-.11.46-.21.91-.28 1.32a35.49 35.49 0 00-.11 8.8q1.42 20.84 2.87 41.65c.27 3.93.54 7.85.9 11.77q1.05 11.38 3 22.67c.06.34.13.69.22 1-8.15 2.59-15.4 7.27-18.45 15.08-1.06 2.7-1.54 5.64-2.84 8.23-1.43 2.84-3.78 5.11-5.34 7.89-2.69 4.78-2.81 10.64-1.83 16 1.89 10.45 7.54 19.79 15 27.39h-1a15.64 15.64 0 00-6.83 2.45c-15.78 9.22-24.8 29-21.51 47.06.65 3.53 1.78 7.11 4.14 9.8a15.51 15.51 0 007.28 4.46 25.29 25.29 0 005.37 1c12.3 1 24.21-4.7 36.54-5.18a98 98 0 0112.23.57q8.91.74 17.85.94c9.69.23 15.14-2.35 21.32-9.59a26.1 26.1 0 003.77-5.94c5.26-.3 11.07-.76 15.27-1.1l.06.58c.23 2 .58 4.3 2.18 5.56a7.61 7.61 0 003 1.23c10.1 2.48 20.32 5 30.72 5a129.71 129.71 0 0014.59-1.12l18.27-2.11a91 91 0 0115.7 3.42c5.28 1.79 10.21 4.45 15.37 6.56 12 4.86 24.9 6.6 37.68 8.3 2.18.29 4.68.49 6.29-1 2.08-2 1.39-5.34.8-8.14-.24-1.15-.42-2.3-.56-3.46a175.25 175.25 0 0125.24 8.76l1.43.63c.42 2.18 2.43 3.92 4.36 6.27a16 16 0 002.21 2.74 7.37 7.37 0 003.17 1.14 147.82 147.82 0 0040.93 1.85 41.86 41.86 0 018.44-.29 36.58 36.58 0 016.1 1.37l11.57 3.32c8.53 2.44 17.26 4.91 26.11 4.36a33.4 33.4 0 005.33-.77c7-1.62 13.52-5.53 16.88-11.82 4.75-8.55 2.56-19.07 0-28.47z" transform="translate(-80.89 -103.35)" fill="url(#undraw_version_control_svg__a)"></path><path d="M125.02 649.54c-2.11-4.8-4.11-10.32-2-15.12a12.85 12.85 0 016.65-6.25 32 32 0 019-2.22 125.61 125.61 0 0129.26-.4c.71 5.62-.79 11.32-2.08 16.75-1.17 5-1.84 5.74-7 6-3.34.18-33.04 3.01-33.83 1.24z" fill="#fbbebe"></path><ellipse cx="214.07" cy="577.16" rx="143" ry="40" fill="#464353"></ellipse><ellipse cx="214.07" cy="577.16" rx="143" ry="40" opacity="0.1"></ellipse><path d="M239.71 366a44.49 44.49 0 01-22.94 20.84 57.58 57.58 0 01-18.21 3.46c-6.79.31-13.72-.13-20.1-2.45-8.56-3.1-15.67-9.44-21-16.83s-9-15.83-12.19-24.34c-1.68-4.43-3.28-9.15-2.49-13.83 5.15-1.17 10.79-2.89 13.45-7.46 2.27-3.92 1.64-8.62.33-13.1-.37-1.27-.8-2.53-1.23-3.74-1-2.9-4.45-8.41-2-10.89 1.53-1.57 7.94-2.37 10.15-3.39 6.81-3.14 13.09-7.68 20.57-9.17 6.47-1.29 13.15-.08 19.61 1.26a6.45 6.45 0 012.42.87 5.82 5.82 0 011.8 2.7c1.84 4.48 2.92 9.43 4.4 14.1 1.54 4.89 3.52 9.48 7.23 12.95 2.89 2.71 6.57 4.41 10.17 6.06l8.86 4.06a11.65 11.65 0 014.19 2.71 10.61 10.61 0 012 5.44 50.82 50.82 0 01-5.02 30.75z" fill="#fbbebe"></path><path d="M212.24 304.03a46 46 0 01-55.67 8.26c-.37-1.27-.8-2.53-1.23-3.74-1-2.9-4.45-8.41-2-10.89 1.53-1.57 7.94-2.37 10.15-3.39 6.81-3.14 13.09-7.68 20.57-9.17 6.47-1.29 13.15-.08 19.61 1.26a6.45 6.45 0 012.42.87 5.82 5.82 0 011.8 2.7c1.79 4.48 2.87 9.43 4.35 14.1z" opacity="0.1"></path><circle cx="179.07" cy="270.16" r="46" fill="#fbbebe"></circle><path d="M319.22 419.45l-3.78-22.9c-1.91-11.49-3.88-23.2-9.22-33.55-3.51-6.78-9.08-13.24-16.59-14.58a16.05 16.05 0 01-4.32-1c-2.2-1.06-3.4-3.44-5.09-5.2-4.36-4.52-11.46-4.59-17.3-6.89-5.16-2-9.38-5.85-14.08-8.79s-10.55-5-15.75-3.12c-.84 8.95-1.73 18.1-5.53 26.25a39.28 39.28 0 01-59.26 14.76c-8.91-6.71-14.62-17.06-17.28-27.89-.65-2.64-1.39-5.67-3.82-6.88-2.63-1.32-5.79.28-8 2.22-4 3.59-7.27 8.73-12.53 9.94-1.9.44-4 .35-5.58 1.5a12.7 12.7 0 00-2.6 3.37 12 12 0 01-10.23 5.06c-1.83-.09-4-.51-5.25.82-.93 1-1 2.56-2 3.49-1.35 1.31-3.54.67-5.42.6-3.56-.15-6.87 2.13-8.91 5s-3 6.42-4 9.86c10.93 24.34 20.93 48.71 31.86 73.05a6.23 6.23 0 01.79 3 7.31 7.31 0 01-1.36 3c-5.36 8.61-5.19 19.44-4.6 29.56s1.31 20.81-3.21 29.88c-1.23 2.49-2.83 4.77-4 7.26-2.74 5.64-3.73 23.68-2.13 29.74h226.08c-4.31-11.85-2.67-35.63-1.77-48.21.63-8.8-1-17.59-1.7-26.39-1.53-17.97-.45-35.02-3.42-52.96z" fill="#b6ce5d"></path><path d="M65.36 445.65a35.4 35.4 0 00-.12 8.73l2.87 41.27c.27 3.89.54 7.77.9 11.65.69 7.53 1.72 15 3 22.46a4 4 0 004.1 3.89c12.65 2.68 25.72 2.57 38.63 1.84 19.7-1.1 39.37-3.61 59.1-3.18 5.08.11 11 0 14.08-4s1.29-10.47-2.73-13.7-9.48-4-14.64-4c-6.83-.07-13.66.9-20.47.5-6.25-.37-12.36-1.88-18.42-3.39l-17-4.23c.65-5.15 2.61-10 4.47-14.89 3.34-8.67 6.46-17.63 6.52-26.92s-3.44-19.06-11.05-24.38c-6.26-4.37-14.32-5.18-21.95-5-5.55.16-15.14-1.17-20.21 1-4.01 1.76-6.33 8.42-7.08 12.35z" fill="#fbbebe"></path><path d="M330.79 540.01c3.33-1.27 7-.81 10.57-.33 11.49 1.57 23.15 3.18 33.8 7.77 5 2.14 9.76 5 13.14 9.21 3 3.79 4.75 8.43 6.41 13l3.84 10.52c1.46 4 2.94 8.08 3.35 12.33 1.2 12.59-7.41 24.46-18.24 31s-23.58 8.87-36 11.31-24.89 5.14-37.26 8a150 150 0 01-17.53 3.45c-13.24 1.5-27.08-.71-39.66 3.67-5 1.75-9.91 4.35-15.1 5.56a93.93 93.93 0 01-10.44 1.59l-23.81 2.72a129.89 129.89 0 01-14.6 1.12c-10.4 0-20.63-2.46-30.73-4.92a7.77 7.77 0 01-3-1.21c-1.6-1.26-1.95-3.49-2.18-5.51q-1.53-13.41-2.68-26.85c-.24-2.91-.42-6.06 1.17-8.51 2-3 5.9-3.94 9.46-4.52a246.88 246.88 0 0145.68-3.17c5.81-5.81 15.39-5.84 23-9a68.39 68.39 0 008.11-4.41 106 106 0 0144.53-14.07 41.45 41.45 0 009.11-1.3c5.89-1.83 11.26-6.81 17.31-5.59.75-2.07 1.27-4.84 3-6.26.86-.73 1.92-1.22 2.71-2 1.67-1.69 1.82-4.35 1.57-6.71s-.81-4.78-.2-7.08a9.79 9.79 0 011.11-2.47c3-5.18 7.53-7.84 13.56-7.34z" fill="#464353"></path><path d="M330.79 540.01c3.33-1.27 7-.81 10.57-.33 11.49 1.57 23.15 3.18 33.8 7.77 5 2.14 9.76 5 13.14 9.21 3 3.79 4.75 8.43 6.41 13l3.84 10.52c1.46 4 2.94 8.08 3.35 12.33 1.2 12.59-7.41 24.46-18.24 31s-23.58 8.87-36 11.31-24.89 5.14-37.26 8a150 150 0 01-17.53 3.45c-13.24 1.5-27.08-.71-39.66 3.67-5 1.75-9.91 4.35-15.1 5.56a93.93 93.93 0 01-10.44 1.59l-23.81 2.72a129.89 129.89 0 01-14.6 1.12c-10.4 0-20.63-2.46-30.73-4.92a7.77 7.77 0 01-3-1.21c-1.6-1.26-1.95-3.49-2.18-5.51q-1.53-13.41-2.68-26.85c-.24-2.91-.42-6.06 1.17-8.51 2-3 5.9-3.94 9.46-4.52a246.88 246.88 0 0145.68-3.17c5.81-5.81 15.39-5.84 23-9a68.39 68.39 0 008.11-4.41 106 106 0 0144.53-14.07 41.45 41.45 0 009.11-1.3c5.89-1.83 11.26-6.81 17.31-5.59.75-2.07 1.27-4.84 3-6.26.86-.73 1.92-1.22 2.71-2 1.67-1.69 1.82-4.35 1.57-6.71s-.81-4.78-.2-7.08a9.79 9.79 0 011.11-2.47c3-5.18 7.53-7.84 13.56-7.34z" opacity="0.05"></path><path d="M134.22 655.72c-6.19 7.17-11.64 9.73-21.33 9.5q-8.94-.21-17.86-.93a100.2 100.2 0 00-12.24-.57c-12.34.48-24.25 6.13-36.56 5.14a25.92 25.92 0 01-5.37-1 15.63 15.63 0 01-7.29-4.42c-2.36-2.67-3.49-6.21-4.14-9.71-3.29-17.94 5.73-37.48 21.52-46.61a15.78 15.78 0 016.84-2.43 16.21 16.21 0 016.92 1.52l.15.06A52.33 52.33 0 0182 617.71a9.66 9.66 0 002.62 2.11 9 9 0 003.09.58l13.14.83a31.14 31.14 0 016.6.91 52.46 52.46 0 016.94 3c7.07 3.16 14.91 4 22.55 5.22a3.37 3.37 0 012 .8 3.13 3.13 0 01.62 1.3 25.51 25.51 0 01-5.34 23.26z" fill="#3f3d56"></path><path d="M64.86 606.28a78.9 78.9 0 00-13.15 16.44 82.28 82.28 0 00-10.74 32.54 60.4 60.4 0 00-.11 12.61 15.63 15.63 0 01-7.29-4.42c-2.36-2.67-3.49-6.21-4.14-9.71-3.29-17.94 5.73-37.48 21.52-46.61a15.78 15.78 0 016.84-2.43 16.21 16.21 0 016.92 1.52z" opacity="0.1"></path><path d="M319.35 631.16c7.35-.2 15.6-.57 21 4.38 5.15 4.68 5.83 12.4 6.17 19.35l.39 8.07c.12 2.46.22 5-.77 7.28-1.76 4-6.59 5.93-11 5.7s-8.46-2.16-12.49-3.9a175.7 175.7 0 00-34-10.71q.57-8.37 1.9-16.66c.61-3.83.71-10.24 3.27-13.42 2.71-3.36 6.24-1.54 9.92-.92a79.63 79.63 0 0015.61.83z" fill="#fbbebe"></path><path d="M125.11 550.07c0 1-1.57 0-1.71-1.07-1.1-8.09-7.52-14.76-15-18s-16-3.41-24.1-2.64c-12.25 1.16-26 5.85-30.48 17.3-1.06 2.68-1.54 5.58-2.84 8.15-1.44 2.82-3.79 5.07-5.35 7.81-2.69 4.74-2.8 10.55-1.83 15.91 2.61 14.3 12.39 26.53 24.24 35s25.7 13.53 39.51 18.09a685.19 685.19 0 00112 26.75c6.16.93 12.38 1.79 18.28 3.77 5.28 1.77 10.22 4.42 15.38 6.5 12 4.82 24.91 6.54 37.7 8.23 2.18.28 4.68.48 6.29-1 2.08-1.93 1.39-5.29.8-8.06a43.35 43.35 0 015.11-30.76c2.14-3.6 4.92-7.29 4.52-11.46-.48-4.86-5.32-8.3-10.14-9.08s-9.72.37-14.56 1c-1.67.22-3.49.36-4.95-.49a9.89 9.89 0 01-1.94-1.72 21.93 21.93 0 00-25.54-3.57c-1.79 1-4.5-1.23-6.36-2.07l-21.03-9.52c-24.16-10.93-48.44-21.91-74-28.83a15.54 15.54 0 01-5.7-2.37c-1.27-1-2.18-2.36-3.35-3.47-2.55-2.41-6.1-3.37-9.16-5.08s-6.49-5.89-5.79-9.32z" fill="#464353"></path><path d="M449.32 680.76c-3.36 6.23-9.88 10.11-16.88 11.71a33.5 33.5 0 01-5.34.76c-8.85.55-17.59-1.9-26.12-4.32l-11.58-3.26a36.55 36.55 0 00-6.1-1.36 41.86 41.86 0 00-8.44.29 149.59 149.59 0 01-41-1.84 7.23 7.23 0 01-3.17-1.13 15.75 15.75 0 01-2.21-2.71c-3.15-3.79-6.54-6-2.81-11 2.15-2.9 6.14-4.35 7.81-7.68s.6-8.06-.39-11.5c-1.35-4.75-5.79-6.8-7.38-11.16-1.19-3.29.81-7.11 3.82-8.9s6.73-1.93 10.2-1.47 6.87 1.44 10.36 1.71c10.26.82 20.75-4.47 30.6-1.49 2.17.66 4.22 1.71 6.42 2.29a21.35 21.35 0 0012.83-1.11c1.44-.54 2.85-1.19 4.25-1.83a34.23 34.23 0 018.55-3.09c9.61-1.65 18.52 5 25.77 11.49a36.44 36.44 0 016.55 7.1c2 3.12 3.06 6.75 4 10.33 2.65 9.25 4.84 19.67.26 28.17z" fill="#3f3d56"></path><path d="M449.32 680.76c-3.36 6.23-9.88 10.11-16.88 11.71a32.69 32.69 0 003.55-17.16c-.6-9.51-4.78-18.47-10.11-26.37a93.4 93.4 0 00-11.14-13.57c-3.18-3.2-7.09-5.74-10.51-8.67a34.23 34.23 0 018.55-3.09c9.61-1.65 18.52 5 25.77 11.49a36.44 36.44 0 016.55 7.1c2 3.12 3.06 6.75 4 10.33 2.61 9.31 4.8 19.73.22 28.23z" opacity="0.1"></path><path d="M82.11 372.26a10.35 10.35 0 00-2.22 3.55 167.86 167.86 0 00-14.1 57.62 5.76 5.76 0 01-.65 2.79 12.21 12.21 0 01-1.47 1.59 5.52 5.52 0 00.94 8c1.65-3.11 5.6-4.12 9.11-4.39 16.81-1.33 33.23 6.49 50.09 5.9-1.19-4.11-2.9-8.06-3.87-12.22-4.29-18.47 6.41-38.58-.15-56.37-1.31-3.56-3.5-7.06-6.95-8.62a18.51 18.51 0 00-4.45-1.18c-4.26-.77-12.74-4.06-16.86-2.74-1.52.49-2.12 1.92-3.38 2.78-1.91 1.23-4.45 1.68-6.04 3.29z" fill="#b6ce5d"></path><rect x="117.57" y="408.66" width="223" height="142" rx="7.97" fill="#3f3d56"></rect><circle cx="228.57" cy="479.66" r="6" fill="#fff"></circle><path d="M147.29 195.5c-3.36 2.43-5.66 5.92-8 9.27-4.31 6.19-9.19 12.37-16.08 15.82-2.61 1.31-5.59 2.3-7.32 4.58a12.34 12.34 0 00-1.95 5.13 101.65 101.65 0 00-2.06 19.6c0 3.28.14 6.66 1.59 9.64 1.37 2.8 3.84 5.17 4.35 8.22.39 2.38-.49 4.75-.8 7.14s.23 5.22 2.44 6.36a14.79 14.79 0 003.7.87c6.65 1.48 8.88 9.28 9.89 15.73 2.26-.13 3.28-2.72 3.75-4.83l6.93-30.81c.75-3.34 2-7.21 5.33-8.38 2.23-.77 4.67-.05 7 .15 9.15.75 16.89-6.32 25.84-8.27a33 33 0 018.71-.58c7.06.35 15.27 3.25 16.77 9.84.25 1.07.4 2.35 1.4 2.88s2.05.08 3.1 0c4.48-.45 7.12 4.59 8.41 8.71l4.7 15c.7 2.27 1.88 4.94 4.34 5.23 2.27.28 4.2-1.87 4.54-4s-.4-4.34-.89-6.48c-2.21-9.85 1.17-19.93 3.23-29.8s2.43-21.21-4.48-28.81c-2.51-2.75-5.81-4.8-8.15-7.7-2.18-2.72-3.41-6.06-5.67-8.73-6.25-7.37-22.28-13.06-32.11-14-11.23-1.22-29.43 1.63-38.51 8.22z" fill="#3f3d56"></path><g opacity="0.1"><path d="M229.37 279.8c-2.46-.3-3.64-3-4.34-5.23q-2.35-7.51-4.7-15c-1.29-4.13-3.93-9.17-8.41-8.71-1.05.11-2.18.52-3.1 0s-1.15-1.81-1.4-2.88c-1.5-6.6-9.71-9.49-16.77-9.84a33.43 33.43 0 00-8.71.57c-8.95 2-16.69 9-25.84 8.27-2.36-.19-4.8-.91-7-.14-3.37 1.16-4.58 5-5.33 8.38l-6.93 30.8c-.47 2.12-1.49 4.71-3.75 4.83-1-6.44-3.24-14.24-9.89-15.72a15.72 15.72 0 01-3.7-.87 4.34 4.34 0 01-1.93-2.15c-.18.93-.39 1.86-.51 2.79-.3 2.38.23 5.22 2.44 6.36a14.79 14.79 0 003.7.87c6.65 1.48 8.88 9.28 9.89 15.73 2.26-.13 3.28-2.72 3.75-4.83l6.93-30.81c.75-3.34 2-7.21 5.33-8.38 2.23-.77 4.67-.05 7 .15 9.15.75 16.89-6.32 25.84-8.27a33 33 0 018.71-.58c7.06.35 15.27 3.25 16.77 9.84.25 1.07.4 2.35 1.4 2.88s2.05.08 3.1 0c4.48-.45 7.12 4.59 8.41 8.71q2.34 7.51 4.7 15c.7 2.27 1.88 4.94 4.34 5.23 2.27.28 4.2-1.87 4.54-4a13.58 13.58 0 00-.6-5.31 4.13 4.13 0 01-3.94 2.31zM117.83 260.76c-.51-3.05-3-5.42-4.35-8.22a16.45 16.45 0 01-1.48-6c0 1.12-.1 2.24-.11 3.37 0 3.28.14 6.66 1.59 9.64 1.11 2.27 2.94 4.27 3.86 6.58a15.06 15.06 0 00.49-5.37zM236.25 239.48c-1.82 8.72-4.66 17.6-3.78 26.34.57-6.45 2.45-12.94 3.78-19.34a51 51 0 001.16-14.83 61.14 61.14 0 01-1.16 7.83z"></path></g><g opacity="0.8"><path fill="none" stroke="#3f3d56" stroke-miterlimit="10" stroke-width="3" d="M330.04 290.49H955.1M385.57 290.48s29.89 4.15 14.41-27.92 42-26 42-26M584.64 290.48s29.89-4.14 14.41 27.93 42 26 42 26M871.27 290.48s-29.9-4.14-14.41 27.93-42 26-42 26M814.86 344.4H649.93"></path><circle cx="330.04" cy="290.49" r="18.25" fill="#b6ce5d"></circle><circle cx="442.29" cy="236.3" r="18.25" fill="#3acc6c"></circle><circle cx="442.29" cy="290.49" r="18.25" fill="#b6ce5d"></circle><circle cx="514.73" cy="290.49" r="18.25" fill="#b6ce5d"></circle><circle cx="641.35" cy="344.13" r="18.25" fill="#ff6584"></circle><circle cx="737.03" cy="344.13" r="18.25" fill="#ff6584"></circle><circle cx="732.04" cy="290.49" r="18.25" fill="#b6ce5d"></circle><circle cx="950.48" cy="290.49" r="18.25" fill="#b6ce5d"></circle><circle cx="861.12" cy="290.49" r="18.25" fill="#b6ce5d"></circle><path fill="#b6ce5d" d="M299.38 122.66h61.23v42.2h-61.23z"></path><path fill="#3acc6c" d="M411.9 122.66h61.23v42.2H411.9z"></path><path fill="#ff6584" d="M610.48 122.66h61.23v42.2h-61.23z"></path></g><path d="M86.35 299.36s-74.77-31.44-84.57 25.29c0 0-5.11 8.84 2 16.14 0 0 1.53-3.92 8.75.13a37.17 37.17 0 008.16 3.32 18.36 18.36 0 0011.62-.62s24.59-1.33 45.27-33.5c0 0 8.87-5.48 9.31-7.54l-14.82 1s1.14 10.85-5 17.36c0 0 5.44-16.84 2.83-17.31-.53-.1-7.83.86-7.83.86s1.89 18.87-8 28.63c0 0 9.18-19.19 5.19-28.29l-10.94 2.11s3 19.85-7.82 31.39c0 0 8.9-20.4 5.46-30.76l-10.47 3.52s2.52 19.41-6.53 29c0 0 7.9-24.61 4.18-28 0 0-9.42 3.82-11.43 6 0 0 1.49 14-4.26 19.05 0 0 3.53-17 1.78-17.7 0 0-10.94 8.24-14.28 15.35 0 0 4.16-10.86 12.91-17 0 0-7.35-1.24-13 1.83 0 0 3.78-7.21 15.65-3.79 0 0 8.79-6.09 10.55-6 0 0-11.23-5-19.34-4.38 0 0 8.7-5 22.08 3.35l10.45-3.77s-14.5-7.43-21.76-7.4c0 0 9.66-3.74 24.47 6.66l10.7-2.18s-12-7.35-20.09-9.06c0 0 9.7-1.54 23.18 8.55l7.31-.61s-8.85-5.22-11.53-6.49-2.56-2.09-2.56-2.09a34.89 34.89 0 0117.14 8.18s15.18-.3 15.24-1.23zM83.59 243s-26.48-61.27-64.63-33.17c0 0-8.06 2.34-8 10.7 0 0 3.14-1.46 5.13 5.07a30.1 30.1 0 003 6.61 15 15 0 007.25 6.25s15.37 13.22 46 5.89c0 0 8.4 1.79 9.83.83l-9.36-7.87s-5.51 7.1-12.89 7.44c0 0 12.83-6.9 11.55-8.67-.26-.36-5.15-3.94-5.15-3.94s-9.62 12.28-21 12.47c0 0 16.39-6.18 19.2-13.85l-7.7-5s-9.71 13.51-22.71 14.21c0 0 16.91-7.05 20.77-15.17l-8.23-3.87s-9.56 13-20.37 13.49c0 0 18.72-10.12 18.43-14.25 0 0-7.77-3.1-10.24-2.92 0 0-7.07 9.15-13.38 8.89 0 0 11.79-8.09 11.15-9.5 0 0-11.2-1.34-17.23 1 0 0 8.66-4.08 17.35-2.74 0 0-3.66-4.93-8.75-6.3 0 0 6.36-2.13 11.46 6.65 0 0 8.68 1.4 9.7 2.44 0 0-3.81-9.39-9-13.62 0 0 8 2 11.2 14.57l8.36 3.71s-4.38-12.68-8.72-16.79c0 0 7.87 3.28 10.75 17.9l7.6 4.79s-2.94-11.2-6.77-16.83c0 0 6.64 4.62 8.89 18.29l4.7 3.8s-2.29-8.14-3.16-10.42-.33-2.7-.33-2.7a28.65 28.65 0 015.49 14.68s9.24 8.44 9.81 7.93z" fill="#b6ce5d" opacity="0.1"></path></svg></div><h3>Use it</h3><p></p><ul><li>Clone it on <a href="https://github.com/pistacheio/pistache">GitHub</a></li><li>Start with the <a href="docs/">quickstart</a></li><li>Read the full user&#x27;s <a href="docs/http-handler">guide</a></li><li>Have issues with it? Fill an <a href="https://github.com/pistacheio/pistache/issues">issue</a></li></ul><p></p></div></div></div></section></main></div><footer class="footer footer--dark"><div class="container"><div class="row footer__links"><div class="col footer__col"><div class="footer__title">Docs</div><ul class="footer__items"><li class="footer__item"><a class="footer__link-item" href="/docs/">Quickstart</a></li><li class="footer__item"><a class="footer__link-item" href="/docs/http-handler/">User guide</a></li></ul></div><div class="col footer__col"><div class="footer__title">Community</div><ul class="footer__items"><li class="footer__item"><a href="https://stackoverflow.com/questions/tagged/pistache" target="_blank" rel="noopener noreferrer" class="footer__link-item">Stack Overflow</a></li><li class="footer__item"><a href="https://web.libera.chat/#pistache" target="_blank" rel="noopener noreferrer" class="footer__link-item">#pistache on Libera.Chat</a></li></ul></div><div class="col footer__col"><div class="footer__title">More</div><ul class="footer__items"><li class="footer__item"><a href="https://github.com/pistacheio/pistache" target="_blank" rel="noopener noreferrer" class="footer__link-item">GitHub</a></li></ul></div></div><div class="footer__bottom text--center"><div class="footer__copyright">Pistache, 2015 - 2021</div></div></div></footer></div>
<script src="/assets/js/runtime~main.53122274.js"></script>
<script src="/assets/js/main.67d7f0b9.js"></script>
<script src="/assets/js/main.0163458a.js"></script>
</body>
</html>
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment