Commit 1a07f80f authored by Mathieu Stefani's avatar Mathieu Stefani

feat(site): draft for new site version

parent a77ee031
(window.webpackJsonp=window.webpackJsonp||[]).push([[3],{52:function(e,t,n){"use strict";n.r(t),n.d(t,"frontMatter",(function(){return i})),n.d(t,"metadata",(function(){return o})),n.d(t,"rightToc",(function(){return r})),n.d(t,"default",(function(){return p}));var a=n(2),s=(n(0),n(73));const i={id:"guide-http-handler",title:"Http Response",sidebar_label:"Http Response"},o={unversionedId:"guide-http-handler",id:"guide-http-handler",isDocsHomePage:!1,title:"Http Response",description:"Sending a response",source:"@site/docs/guide-http-handler.md",permalink:"/docs/guide-http-handler",editUrl:"https://github.com/facebook/docusaurus/edit/master/website/docs/guide-http-handler.md",sidebar_label:"Http Response",sidebar:"someSidebar",previous:{title:"Hello World",permalink:"/docs/getting-started-hello-world"},next:{title:"Namespace",permalink:"/docs/namespace"}},r=[],c={rightToc:r};function p({components:e,...t}){return Object(s.b)("wrapper",Object(a.a)({},c,t,{components:e,mdxType:"MDXLayout"}),Object(s.b)("h1",{id:"sending-a-response"},"Sending a response"),Object(s.b)("p",null,Object(s.b)("inlineCode",{parentName:"p"},"ResponseWriter")," is an object from which the final http response is sent to the client.\nThe ",Object(s.b)("inlineCode",{parentName:"p"},"onRequest()")," function does not return anything.\nInstead, the response is sent through the ",Object(s.b)("inlineCode",{parentName:"p"},"ResponseWriter")," class.\nThis class provides a bunch of ",Object(s.b)("inlineCode",{parentName:"p"},"send()")," function overloads to send the response:"),Object(s.b)("pre",null,Object(s.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cpp"}),"Async::Promise<ssize_t> send(Code code);\n")),Object(s.b)("p",null,"You can use this overload to send a response with an empty body and a given HTTP Code (e.g ",Object(s.b)("inlineCode",{parentName:"p"},"Http::Code::Ok"),")"),Object(s.b)("pre",null,Object(s.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cpp"}),"Async::Promise<ssize_t> send(Code code, const std::string& body, const Mime::MediaType &mime = Mime::MediaType());\n")),Object(s.b)("p",null,"This overload can be used to send a response with static, fixed-size content (body).\nA MIME type can also be specified, which will be sent through the ",Object(s.b)("inlineCode",{parentName:"p"},"Content-Type")," header."),Object(s.b)("pre",null,Object(s.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cpp"}),"template<size_t N>\nAsync::Promise<ssize_t> send(Code code, const char (&arr)[N], const Mime::MediaType& mime = Mime::MediaType());\n")),Object(s.b)("p",null,"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."),Object(s.b)("p",null,"These functions are asynchronous, meaning that they do not return a plain old ",Object(s.b)("inlineCode",{parentName:"p"},"ssize_t")," value indicating the number of bytes being sent,\nbut instead a ",Object(s.b)("inlineCode",{parentName:"p"},"Promise")," that will be fulfilled later on."),Object(s.b)("p",null,"See the next section for more details on asynchronous programming with Pistache."),Object(s.b)("h1",{id:"response-streaming"},"Response streaming"),Object(s.b)("p",null,"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."),Object(s.b)("p",null,"For that matter, the HTTP specification defines a special data-transfer mechanism called ",Object(s.b)("a",Object(a.a)({parentName:"p"},{href:"http://tools.ietf.org/html/rfc7230#section-4.1"}),"chunked encoding"),"\nwhere data is sent in a series of chunks.\nThis mechanism uses the ",Object(s.b)("inlineCode",{parentName:"p"},"Transfer-Encoding")," HTTP header in place of the Content-Length one."),Object(s.b)("p",null,"To stream content, Pistache provides a special ",Object(s.b)("inlineCode",{parentName:"p"},"ResponseStream")," class. To get a ",Object(s.b)("inlineCode",{parentName:"p"},"ResponseStream")," from a ",Object(s.b)("inlineCode",{parentName:"p"},"ResponseWriter"),", call the ",Object(s.b)("inlineCode",{parentName:"p"},"stream()")," member function:"),Object(s.b)("pre",null,Object(s.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cpp"}),"auto stream = response.stream(Http::Code::Ok);\n")),Object(s.b)("p",null,"To initate a stream, you have to pass the HTTP status code to the stream function (here ",Object(s.b)("inlineCode",{parentName:"p"},"Http::Code::Ok")," or HTTP 200).\nThe ",Object(s.b)("inlineCode",{parentName:"p"},"ResponseStream")," class provides an iostream like interface that overloads the ",Object(s.b)("inlineCode",{parentName:"p"},"<<")," operator."),Object(s.b)("pre",null,Object(s.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cpp"}),'stream << "PO"\nstream << "NG"\n')),Object(s.b)("p",null,'The first line will write a chunk of size 2 with the content "PO" to the stream\u2019s buffer.\nThe second line will write a second chunk of size 2 with the content "NG".\nTo end the stream and flush the content, use the special ',Object(s.b)("inlineCode",{parentName:"p"},"ends")," marker:"),Object(s.b)("pre",null,Object(s.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cpp"}),"stream << ends\n")),Object(s.b)("p",null,"The ",Object(s.b)("inlineCode",{parentName:"p"},"ends")," marker will write the last chunk of size 0 and send the final data over the network.\nTo simply flush the stream\u2019s buffer without ending the stream, you can use the ",Object(s.b)("inlineCode",{parentName:"p"},"flush")," marker:"),Object(s.b)("pre",null,Object(s.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cpp"}),"stream << flush\n")),Object(s.b)("div",{className:"admonition admonition-caution alert alert--warning"},Object(s.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(s.b)("h5",{parentName:"div"},Object(s.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(s.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"16",height:"16",viewBox:"0 0 16 16"}),Object(s.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"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"})))),"HTTP headers")),Object(s.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(s.b)("p",{parentName:"div"},"After starting a stream, headers become immutable. They must be written to the response before creating a ",Object(s.b)("inlineCode",{parentName:"p"},"ResponseStream"),":"),Object(s.b)("pre",{parentName:"div"},Object(s.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cpp"}),'response.headers()\n .add<Header::Server>("lys")\n .add<Header::ContentType>(MIME(Text, Plain));\n\nauto stream = response.stream();\nstream << "PO" << "NG" << ends;\n')))))}p.isMDXComponent=!0}}]);
\ No newline at end of file
This diff is collapsed.
(window.webpackJsonp=window.webpackJsonp||[]).push([[14],{79:function(e,t,a){"use strict";a.r(t);var n=a(0),o=a.n(n),l=a(76);t.default=function(){return o.a.createElement(l.a,{title:"Page Not Found"},o.a.createElement("div",{className:"container margin-vert--xl"},o.a.createElement("div",{className:"row"},o.a.createElement("div",{className:"col col--6 col--offset-3"},o.a.createElement("h1",{className:"hero__title"},"Page Not Found"),o.a.createElement("p",null,"We could not find what you were looking for."),o.a.createElement("p",null,"Please contact the owner of the site that linked you to the original URL and let them know their link is broken.")))))}}}]);
\ No newline at end of file
(window.webpackJsonp=window.webpackJsonp||[]).push([[4],{68:function(e,t,a){"use strict";a.r(t);var n=a(0),l=a.n(n),r=a(80),i=a(69),c=a(72),o=a(71);var s=function(e){const{metadata:t}=e;return l.a.createElement("nav",{className:"pagination-nav","aria-label":"Blog list page navigation"},l.a.createElement("div",{className:"pagination-nav__item"},t.previous&&l.a.createElement(o.a,{className:"pagination-nav__link",to:t.previous.permalink},l.a.createElement("div",{className:"pagination-nav__sublabel"},"Previous"),l.a.createElement("div",{className:"pagination-nav__label"},"\xab ",t.previous.title))),l.a.createElement("div",{className:"pagination-nav__item pagination-nav__item--next"},t.next&&l.a.createElement(o.a,{className:"pagination-nav__link",to:t.next.permalink},l.a.createElement("div",{className:"pagination-nav__sublabel"},"Next"),l.a.createElement("div",{className:"pagination-nav__label"},t.next.title," \xbb"))))};var m=function(e,t,a){const[l,r]=Object(n.useState)(void 0);Object(n.useEffect)(()=>{let n,i;function c(){const c=function(){let e=0,t=null;for(n=document.getElementsByClassName("anchor");e<n.length&&!t;){const l=n[e],{top:r}=l.getBoundingClientRect();r>=0&&r<=a&&(t=l),e+=1}return t}();if(c){let a=0,n=!1;for(i=document.getElementsByClassName(e);a<i.length&&!n;){const e=i[a],{href:o}=e,s=decodeURIComponent(o.substring(o.indexOf("#")+1));c.id===s&&(l&&l.classList.remove(t),e.classList.add(t),r(e),n=!0),a+=1}}}return document.addEventListener("scroll",c),document.addEventListener("resize",c),c(),()=>{document.removeEventListener("scroll",c),document.removeEventListener("resize",c)}})},d=a(78);var u=function(){const{siteConfig:{title:e}}=Object(i.a)(),t=(()=>{const e=Object(d.useActivePlugin)();if(!e)throw new Error("DocVersionCallout is only supposed to be used on docs-related routes");return e.pluginId})(),a=Object(d.useActiveVersion)(t),{latestDocSuggestion:n,latestVersionSuggestion:r}=Object(d.useDocVersionSuggestions)(t);if(!r)return l.a.createElement(l.a.Fragment,null);const c=a.name,s=null!=n?n:(m=r).docs.find(e=>e.id===m.mainDocId);var m;return l.a.createElement("div",{className:"alert alert--warning margin-bottom--md",role:"alert"},"next"===c?l.a.createElement("div",null,"This is unreleased documentation for ",e," ",l.a.createElement("strong",null,c)," version."):l.a.createElement("div",null,"This is documentation for ",e," ",l.a.createElement("strong",null,"v",c),", which is no longer actively maintained."),l.a.createElement("div",{className:"margin-top--md"},"For up-to-date documentation, see the"," ",l.a.createElement("strong",null,l.a.createElement(o.a,{to:s.path},"latest version"))," ","(",r.name,")."))},g=a(70),E=a(53),v=a.n(E);function p({headings:e}){return m("table-of-contents__link","table-of-contents__link--active",100),l.a.createElement("div",{className:"col col--3"},l.a.createElement("div",{className:v.a.tableOfContents},l.a.createElement(h,{headings:e})))}function h({headings:e,isChild:t}){return e.length?l.a.createElement("ul",{className:t?"":"table-of-contents table-of-contents__left-border"},e.map(e=>l.a.createElement("li",{key:e.id},l.a.createElement("a",{href:"#"+e.id,className:"table-of-contents__link",dangerouslySetInnerHTML:{__html:e.value}}),l.a.createElement(h,{isChild:!0,headings:e.children})))):null}t.default=function(e){const{siteConfig:t={}}=Object(i.a)(),{url:a,title:n}=t,{content:o}=e,{metadata:m}=o,{description:d,title:E,permalink:h,editUrl:f,lastUpdatedAt:b,lastUpdatedBy:_,version:N}=m,{frontMatter:{image:w,keywords:y,hide_title:k,hide_table_of_contents:C}}=o,O=E?`${E} | ${n}`:n,j=Object(c.a)(w,{absolute:!0});return l.a.createElement(l.a.Fragment,null,l.a.createElement(r.a,null,l.a.createElement("title",null,O),l.a.createElement("meta",{property:"og:title",content:O}),d&&l.a.createElement("meta",{name:"description",content:d}),d&&l.a.createElement("meta",{property:"og:description",content:d}),y&&y.length&&l.a.createElement("meta",{name:"keywords",content:y.join(",")}),w&&l.a.createElement("meta",{property:"og:image",content:j}),w&&l.a.createElement("meta",{property:"twitter:image",content:j}),w&&l.a.createElement("meta",{name:"twitter:image:alt",content:"Image for "+E}),h&&l.a.createElement("meta",{property:"og:url",content:a+h}),h&&l.a.createElement("link",{rel:"canonical",href:a+h})),l.a.createElement("div",{className:Object(g.a)("container padding-vert--lg",v.a.docItemWrapper)},l.a.createElement("div",{className:"row"},l.a.createElement("div",{className:Object(g.a)("col",{[v.a.docItemCol]:!C})},l.a.createElement(u,null),l.a.createElement("div",{className:v.a.docItemContainer},l.a.createElement("article",null,N&&l.a.createElement("div",null,l.a.createElement("span",{className:"badge badge--secondary"},"Version: ",N)),!k&&l.a.createElement("header",null,l.a.createElement("h1",{className:v.a.docTitle},E)),l.a.createElement("div",{className:"markdown"},l.a.createElement(o,null))),(f||b||_)&&l.a.createElement("div",{className:"margin-vert--xl"},l.a.createElement("div",{className:"row"},l.a.createElement("div",{className:"col"},f&&l.a.createElement("a",{href:f,target:"_blank",rel:"noreferrer noopener"},l.a.createElement("svg",{fill:"currentColor",height:"1.2em",width:"1.2em",preserveAspectRatio:"xMidYMid meet",viewBox:"0 0 40 40",style:{marginRight:"0.3em",verticalAlign:"sub"}},l.a.createElement("g",null,l.a.createElement("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"}))),"Edit this page")),(b||_)&&l.a.createElement("div",{className:"col text--right"},l.a.createElement("em",null,l.a.createElement("small",null,"Last updated"," ",b&&l.a.createElement(l.a.Fragment,null,"on"," ",l.a.createElement("time",{dateTime:new Date(1e3*b).toISOString(),className:v.a.docLastUpdatedAt},new Date(1e3*b).toLocaleDateString()),_&&" "),_&&l.a.createElement(l.a.Fragment,null,"by ",l.a.createElement("strong",null,_)),!1))))),l.a.createElement("div",{className:"margin-vert--lg"},l.a.createElement(s,{metadata:m})))),!C&&o.rightToc&&l.a.createElement(p,{headings:o.rightToc}))))}}}]);
\ No newline at end of file
This diff is collapsed.
/*!
Copyright (c) 2017 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/
(window.webpackJsonp=window.webpackJsonp||[]).push([[5],{60:function(e){e.exports=JSON.parse('{"docsSidebars":{"someSidebar":[{"collapsed":true,"type":"category","label":"Getting Started","items":[{"type":"link","label":"Installation","href":"/docs/"},{"type":"link","label":"Hello World","href":"/docs/getting-started-hello-world"}]},{"collapsed":true,"type":"category","label":"Guide","items":[{"type":"link","label":"Http Response","href":"/docs/guide-http-handler"}]},{"collapsed":true,"type":"category","label":"API Reference","items":[{"type":"link","label":"Namespace","href":"/docs/namespace"}]}]},"permalinkToSidebar":{"/docs/":"someSidebar","/docs/getting-started-hello-world":"someSidebar","/docs/guide-http-handler":"someSidebar","/docs/namespace":"someSidebar"},"version":null}')}}]);
\ No newline at end of file
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="generator" content="Docusaurus v2.0.0-alpha.61">
<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" name="twitter:card" content="summary_large_image"><link data-react-helmet="true" rel="shortcut icon" href="/img/favicon.ico"><link rel="stylesheet" href="/styles.6eaf09fd.css">
<link rel="preload" href="/styles.95b3468f.js" as="script">
<link rel="preload" href="/runtime~main.55b5505e.js" as="script">
<link rel="preload" href="/main.95ce440f.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">
<nav class="navbar navbar--light navbar--fixed-top"><div class="navbar__inner"><div class="navbar__items"><div aria-label="Navigation bar toggle" class="navbar__toggle" role="button" tabindex="0"><svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 30 30" role="img" focusable="false"><title>Menu</title><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></div><a class="navbar__brand" href="/"><img class="navbar__logo" src="/img/logo.png" alt="Pistache logo"><strong class="navbar__title">Pistache</strong></a><a class="navbar__item navbar__link" href="/docs/">Docs</a></div><div class="navbar__items navbar__items--right"><div class="react-toggle react-toggle--disabled displayOnlyInLargeViewport_2aTZ"><div class="react-toggle-track"><div class="react-toggle-track-check"><span class="toggle_BsTx">🌜</span></div><div class="react-toggle-track-x"><span class="toggle_BsTx">🌞</span></div></div><div class="react-toggle-thumb"></div><input type="checkbox" disabled="" aria-label="Dark mode toggle" class="react-toggle-screenreader-only"></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 class="navbar__logo" src="/img/logo.png" alt="Pistache logo"><strong class="navbar__title">Pistache</strong></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></ul></div></div></div></nav><div class="main-wrapper"><div 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></div></div><footer class="footer footer--dark"><div class="container"><div class="row footer__links"><div class="col footer__col"><h4 class="footer__title">Docs</h4><ul class="footer__items"><li class="footer__item"><a class="footer__link-item" href="/docs/">Documentation</a></li></ul></div><div class="col footer__col"><h4 class="footer__title">Community</h4><ul class="footer__items"><li class="footer__item"><a href="https://stackoverflow.com/questions/tagged/docusaurus" target="_blank" rel="noopener noreferrer" class="footer__link-item">Stack Overflow</a></li><li class="footer__item"><a href="https://discordapp.com/invite/docusaurus" target="_blank" rel="noopener noreferrer" class="footer__link-item">Discord</a></li><li class="footer__item"><a href="https://twitter.com/docusaurus" target="_blank" rel="noopener noreferrer" class="footer__link-item">Twitter</a></li></ul></div></div><div class="text--center"><div>Copyright © 2020 Pistache. Built with Docusaurus.</div></div></div></footer></div>
<script src="/styles.95b3468f.js"></script>
<script src="/runtime~main.55b5505e.js"></script>
<script src="/main.95ce440f.js"></script>
</body>
</html>
\ No newline at end of file
(window.webpackJsonp=window.webpackJsonp||[]).push([[6],{61:function(e,t,a){"use strict";a.r(t),a.d(t,"frontMatter",(function(){return c})),a.d(t,"metadata",(function(){return i})),a.d(t,"rightToc",(function(){return o})),a.d(t,"default",(function(){return r}));var n=a(2),s=(a(0),a(73));const c={id:"namespace",title:"Namespace",sidebar_label:"Namespace"},i={unversionedId:"namespace",id:"namespace",isDocsHomePage:!1,title:"Namespace",description:"Most of the components provided by Pistache live in the Pistache namespace.",source:"@site/docs/namespace.md",permalink:"/docs/namespace",editUrl:"https://github.com/facebook/docusaurus/edit/master/website/docs/namespace.md",sidebar_label:"Namespace",sidebar:"someSidebar",previous:{title:"Http Response",permalink:"/docs/guide-http-handler"}},o=[],p={rightToc:o};function r({components:e,...t}){return Object(s.b)("wrapper",Object(n.a)({},p,t,{components:e,mdxType:"MDXLayout"}),Object(s.b)("p",null,"Most of the components provided by Pistache live in the ",Object(s.b)("inlineCode",{parentName:"p"},"Pistache")," namespace.\nIt is thus recommended to directly import this namespace with a ",Object(s.b)("inlineCode",{parentName:"p"},"using-declaration"),":"),Object(s.b)("pre",null,Object(s.b)("code",Object(n.a)({parentName:"pre"},{className:"language-cpp"}),"using namespace Pistache;\n")))}r.isMDXComponent=!0}}]);
\ No newline at end of file
(window.webpackJsonp=window.webpackJsonp||[]).push([[7],{62:function(e,t,n){"use strict";n.r(t),n.d(t,"frontMatter",(function(){return l})),n.d(t,"metadata",(function(){return o})),n.d(t,"rightToc",(function(){return s})),n.d(t,"default",(function(){return c}));var i=n(2),a=(n(0),n(73));const l={id:"getting-started-installation",title:"Installation",sidebar_label:"Installation"},o={unversionedId:"getting-started-installation",id:"getting-started-installation",isDocsHomePage:!0,title:"Installation",description:"Requirements",source:"@site/docs/getting-started-requirements.md",permalink:"/docs/",editUrl:"https://github.com/facebook/docusaurus/edit/master/website/docs/getting-started-requirements.md",sidebar_label:"Installation",sidebar:"someSidebar",next:{title:"Hello World",permalink:"/docs/getting-started-hello-world"}},s=[],r={rightToc:s};function c({components:e,...t}){return Object(a.b)("wrapper",Object(i.a)({},r,t,{components:e,mdxType:"MDXLayout"}),Object(a.b)("h1",{id:"requirements"},"Requirements"),Object(a.b)("p",null,Object(a.b)("inlineCode",{parentName:"p"},"git")," is needed to retrieve the sources.]\nCompiling the sources will require ",Object(a.b)("inlineCode",{parentName:"p"},"CMake")," to generate Makefile and a recent version of ",Object(a.b)("inlineCode",{parentName:"p"},"g++")," (at least 4.7)."),Object(a.b)("p",null,"Also, Pistache does not support Windows yet."),Object(a.b)("h1",{id:"installing-pistache"},"Installing Pistache"),Object(a.b)("p",null,"To download the latest available release, clone the repository over github."),Object(a.b)("p",null,Object(a.b)("inlineCode",{parentName:"p"},"git clone https://github.com/oktal/pistache.git")),Object(a.b)("p",null,"Then, init the submodules:"),Object(a.b)("p",null,Object(a.b)("inlineCode",{parentName:"p"},"git submodule update --init")),Object(a.b)("p",null,"Finally, compile the sources:"),Object(a.b)("pre",null,Object(a.b)("code",Object(i.a)({parentName:"pre"},{className:"language-bash"}),'cd pistache\nmkdir build\ncd build\ncmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release ..\nmake\nsudo make install\n')),Object(a.b)("p",null,"Optionally, you can also run the tests:"),Object(a.b)("p",null,Object(a.b)("inlineCode",{parentName:"p"},"make test")),Object(a.b)("p",null,"Be patient, ",Object(a.b)("inlineCode",{parentName:"p"},"async_test")," can take some time before completing."),Object(a.b)("p",null,"And that\u2019s it, now you can start playing with your newly installed ",Object(a.b)("inlineCode",{parentName:"p"},"Pistache")," framework."))}c.isMDXComponent=!0}}]);
\ No newline at end of file
(window.webpackJsonp=window.webpackJsonp||[]).push([[8],{63:function(e,t,a){"use strict";a.r(t);var n=a(2),l=a(0),r=a.n(l),c=a(70),s=a(76),i=a(71),o=a(69),m=a(72),u=a(64),d=a.n(u),g=[{title:r.a.createElement(r.a.Fragment,null,"Easy to Use"),imageUrl:"img/easy.jpg",description:r.a.createElement(r.a.Fragment,null,"Pistache's API was designed to be easy to use and let you build your http server quickly")},{title:r.a.createElement(r.a.Fragment,null,"Asynchronous"),imageUrl:"img/async.png",description:r.a.createElement(r.a.Fragment,null,"Pistache's API is fully asynchronous, meaning that the web server will not block your threads")}];function E(e){var t=e.imageUrl,a=e.title,n=e.description,l=Object(m.a)(t);return r.a.createElement("div",{className:Object(c.a)("col col--4",d.a.feature)},l&&r.a.createElement("div",{className:"text--center"},r.a.createElement("img",{className:d.a.featureImage,src:l,alt:a})),r.a.createElement("h3",null,a),r.a.createElement("p",null,n))}t.default=function(){var e=Object(o.a)().siteConfig,t=void 0===e?{}:e;return r.a.createElement(s.a,{title:"Hello from "+t.title,description:"Description will go into a meta tag in <head />"},r.a.createElement("header",{className:Object(c.a)("hero hero--primary",d.a.heroBanner)},r.a.createElement("div",{className:"container"},r.a.createElement("h1",{className:"hero__title"},t.title),r.a.createElement("p",{className:"hero__subtitle"},t.tagline),r.a.createElement("div",{className:d.a.buttons},r.a.createElement(i.a,{className:Object(c.a)("button button--outline button--secondary button--lg",d.a.getStarted),to:Object(m.a)("docs/")},"Get Started")))),r.a.createElement("main",null,g&&g.length>0&&r.a.createElement("section",{className:d.a.features},r.a.createElement("div",{className:"container"},r.a.createElement("div",{className:"row"},g.map((function(e,t){return r.a.createElement(E,Object(n.a)({key:t},e))})))))))}}}]);
\ No newline at end of file
(window.webpackJsonp=window.webpackJsonp||[]).push([[9],{65:function(e,t,o){"use strict";o.r(t),o.d(t,"frontMatter",(function(){return c})),o.d(t,"metadata",(function(){return a})),o.d(t,"rightToc",(function(){return d})),o.d(t,"Highlight",(function(){return i})),o.d(t,"default",(function(){return u}));var n=o(2),r=(o(0),o(73));const c={id:"mdx",title:"Powered by MDX"},a={unversionedId:"mdx",id:"mdx",isDocsHomePage:!1,title:"Powered by MDX",description:"You can write JSX and use React components within your Markdown thanks to MDX.",source:"@site/docs/mdx.md",permalink:"/docs/mdx",editUrl:"https://github.com/facebook/docusaurus/edit/master/website/docs/mdx.md"},d=[],i=({children:e,color:t})=>Object(r.b)("span",{style:{backgroundColor:t,borderRadius:"2px",color:"#fff",padding:"0.2rem"}},e),s={rightToc:d,Highlight:i};function u({components:e,...t}){return Object(r.b)("wrapper",Object(n.a)({},s,t,{components:e,mdxType:"MDXLayout"}),Object(r.b)("p",null,"You can write JSX and use React components within your Markdown thanks to ",Object(r.b)("a",Object(n.a)({parentName:"p"},{href:"https://mdxjs.com/"}),"MDX"),"."),Object(r.b)(i,{color:"#25c2a0",mdxType:"Highlight"},"Docusaurus green")," and ",Object(r.b)(i,{color:"#1877F2",mdxType:"Highlight"},"Facebook blue")," are my favorite colors.",Object(r.b)("p",null,"I can write ",Object(r.b)("strong",{parentName:"p"},"Markdown")," alongside my ",Object(r.b)("em",{parentName:"p"},"JSX"),"!"))}u.isMDXComponent=!0}}]);
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="generator" content="Docusaurus v2.0.0-alpha.61">
<title data-react-helmet="true">Powered by MDX | Pistache</title><meta data-react-helmet="true" name="twitter:card" content="summary_large_image"><meta data-react-helmet="true" property="og:title" content="Powered by MDX | Pistache"><meta data-react-helmet="true" name="description" content="You can write JSX and use React components within your Markdown thanks to MDX."><meta data-react-helmet="true" property="og:description" content="You can write JSX and use React components within your Markdown thanks to MDX."><meta data-react-helmet="true" property="og:url" content="http://pistache.io/docs/mdx"><link data-react-helmet="true" rel="shortcut icon" href="/img/favicon.ico"><link data-react-helmet="true" rel="canonical" href="http://pistache.io/docs/mdx"><link rel="stylesheet" href="/styles.6eaf09fd.css">
<link rel="preload" href="/styles.95b3468f.js" as="script">
<link rel="preload" href="/runtime~main.55b5505e.js" as="script">
<link rel="preload" href="/main.95ce440f.js" as="script">
<link rel="preload" href="/common.ab9d3a49.js" as="script">
<link rel="preload" href="/2.665d4957.js" as="script">
<link rel="preload" href="/13.c221dbe8.js" as="script">
<link rel="preload" href="/14.f8f83444.js" as="script">
<link rel="preload" href="/20ac7829.f0b11e5c.js" as="script">
<link rel="preload" href="/17896441.da41daa1.js" as="script">
<link rel="preload" href="/ce3e42ad.8ef4b1bb.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">
<nav class="navbar navbar--light navbar--fixed-top"><div class="navbar__inner"><div class="navbar__items"><div aria-label="Navigation bar toggle" class="navbar__toggle" role="button" tabindex="0"><svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 30 30" role="img" focusable="false"><title>Menu</title><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></div><a class="navbar__brand" href="/"><img class="navbar__logo" src="/img/logo.png" alt="Pistache logo"><strong class="navbar__title">Pistache</strong></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"><div class="react-toggle react-toggle--disabled displayOnlyInLargeViewport_2aTZ"><div class="react-toggle-track"><div class="react-toggle-track-check"><span class="toggle_BsTx">🌜</span></div><div class="react-toggle-track-x"><span class="toggle_BsTx">🌞</span></div></div><div class="react-toggle-thumb"></div><input type="checkbox" disabled="" aria-label="Dark mode toggle" class="react-toggle-screenreader-only"></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 class="navbar__logo" src="/img/logo.png" alt="Pistache logo"><strong class="navbar__title">Pistache</strong></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></ul></div></div></div></nav><div class="main-wrapper"><div class="docPage_2gpo"><main class="docMainContainer_3EyW"><div class="container padding-vert--lg docItemWrapper_1EkI"><div class="row"><div class="col docItemCol_2ASc"><div class="docItemContainer_3QWW"><article><header><h1 class="docTitle_1Lrw">Powered by MDX</h1></header><div class="markdown"><p>You can write JSX and use React components within your Markdown thanks to <a href="https://mdxjs.com/" target="_blank" rel="noopener noreferrer">MDX</a>.</p><span style="background-color:#25c2a0;border-radius:2px;color:#fff;padding:0.2rem">Docusaurus green</span> and <span style="background-color:#1877F2;border-radius:2px;color:#fff;padding:0.2rem">Facebook blue</span> are my favorite colors.<p>I can write <strong>Markdown</strong> alongside my <em>JSX</em>!</p></div></article><div class="margin-vert--xl"><div class="row"><div class="col"><a href="https://github.com/facebook/docusaurus/edit/master/website/docs/mdx.md" target="_blank" rel="noreferrer noopener"><svg fill="currentColor" height="1.2em" width="1.2em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 40 40" style="margin-right:0.3em;vertical-align:sub"><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></div><div class="margin-vert--lg"><nav class="pagination-nav" aria-label="Blog list page navigation"><div class="pagination-nav__item"></div><div class="pagination-nav__item pagination-nav__item--next"></div></nav></div></div></div><div class="col col--3"><div class="tableOfContents_3klQ"></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"><h4 class="footer__title">Docs</h4><ul class="footer__items"><li class="footer__item"><a class="footer__link-item" href="/docs/">Documentation</a></li></ul></div><div class="col footer__col"><h4 class="footer__title">Community</h4><ul class="footer__items"><li class="footer__item"><a href="https://stackoverflow.com/questions/tagged/docusaurus" target="_blank" rel="noopener noreferrer" class="footer__link-item">Stack Overflow</a></li><li class="footer__item"><a href="https://discordapp.com/invite/docusaurus" target="_blank" rel="noopener noreferrer" class="footer__link-item">Discord</a></li><li class="footer__item"><a href="https://twitter.com/docusaurus" target="_blank" rel="noopener noreferrer" class="footer__link-item">Twitter</a></li></ul></div></div><div class="text--center"><div>Copyright © 2020 Pistache. Built with Docusaurus.</div></div></div></footer></div>
<script src="/styles.95b3468f.js"></script>
<script src="/runtime~main.55b5505e.js"></script>
<script src="/main.95ce440f.js"></script>
<script src="/common.ab9d3a49.js"></script>
<script src="/2.665d4957.js"></script>
<script src="/13.c221dbe8.js"></script>
<script src="/14.f8f83444.js"></script>
<script src="/20ac7829.f0b11e5c.js"></script>
<script src="/17896441.da41daa1.js"></script>
<script src="/ce3e42ad.8ef4b1bb.js"></script>
</body>
</html>
\ No newline at end of file
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="generator" content="Docusaurus v2.0.0-alpha.61">
<title data-react-helmet="true">Namespace | Pistache</title><meta data-react-helmet="true" name="twitter:card" content="summary_large_image"><meta data-react-helmet="true" property="og:title" content="Namespace | Pistache"><meta data-react-helmet="true" name="description" content="Most of the components provided by Pistache live in the Pistache namespace."><meta data-react-helmet="true" property="og:description" content="Most of the components provided by Pistache live in the Pistache namespace."><meta data-react-helmet="true" property="og:url" content="http://pistache.io/docs/namespace"><link data-react-helmet="true" rel="shortcut icon" href="/img/favicon.ico"><link data-react-helmet="true" rel="canonical" href="http://pistache.io/docs/namespace"><link rel="stylesheet" href="/styles.6eaf09fd.css">
<link rel="preload" href="/styles.95b3468f.js" as="script">
<link rel="preload" href="/runtime~main.55b5505e.js" as="script">
<link rel="preload" href="/main.95ce440f.js" as="script">
<link rel="preload" href="/common.ab9d3a49.js" as="script">
<link rel="preload" href="/2.665d4957.js" as="script">
<link rel="preload" href="/13.c221dbe8.js" as="script">
<link rel="preload" href="/14.f8f83444.js" as="script">
<link rel="preload" href="/20ac7829.f0b11e5c.js" as="script">
<link rel="preload" href="/17896441.da41daa1.js" as="script">
<link rel="preload" href="/a0dbb6f7.5d49e106.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">
<nav class="navbar navbar--light navbar--fixed-top"><div class="navbar__inner"><div class="navbar__items"><div aria-label="Navigation bar toggle" class="navbar__toggle" role="button" tabindex="0"><svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 30 30" role="img" focusable="false"><title>Menu</title><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></div><a class="navbar__brand" href="/"><img class="navbar__logo" src="/img/logo.png" alt="Pistache logo"><strong class="navbar__title">Pistache</strong></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"><div class="react-toggle react-toggle--disabled displayOnlyInLargeViewport_2aTZ"><div class="react-toggle-track"><div class="react-toggle-track-check"><span class="toggle_BsTx">🌜</span></div><div class="react-toggle-track-x"><span class="toggle_BsTx">🌞</span></div></div><div class="react-toggle-thumb"></div><input type="checkbox" disabled="" aria-label="Dark mode toggle" class="react-toggle-screenreader-only"></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 class="navbar__logo" src="/img/logo.png" alt="Pistache logo"><strong class="navbar__title">Pistache</strong></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></ul></div></div></div></nav><div class="main-wrapper"><div class="docPage_2gpo"><div class="docSidebarContainer_3_JD" role="complementary"><div class="sidebar_2urC"><div class="menu menu--responsive menu_5FrY"><button aria-label="Open Menu" aria-haspopup="true" class="button button--secondary button--sm menu__button" type="button"><svg aria-label="Menu" class="sidebarMenuIcon_Dm3K" xmlns="http://www.w3.org/2000/svg" height="24" width="24" viewBox="0 0 32 32" role="img" focusable="false"><title>Menu</title><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 menu__list-item--collapsed"><a class="menu__link menu__link--sublist" href="#!">Getting Started</a><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" tabindex="-1" href="/docs/">Installation</a></li><li class="menu__list-item"><a class="menu__link" tabindex="-1" href="/docs/getting-started-hello-world">Hello World</a></li></ul></li><li class="menu__list-item menu__list-item--collapsed"><a class="menu__link menu__link--sublist" href="#!">Guide</a><ul class="menu__list"><li class="menu__list-item"><a class="menu__link" tabindex="-1" href="/docs/guide-http-handler">Http Response</a></li></ul></li><li class="menu__list-item"><a class="menu__link menu__link--sublist menu__link--active" href="#!">API Reference</a><ul class="menu__list"><li class="menu__list-item"><a aria-current="page" class="menu__link menu__link--active active" tabindex="0" href="/docs/namespace">Namespace</a></li></ul></li></ul></div></div></div><main class="docMainContainer_3EyW"><div class="container padding-vert--lg docItemWrapper_1EkI"><div class="row"><div class="col docItemCol_2ASc"><div class="docItemContainer_3QWW"><article><header><h1 class="docTitle_1Lrw">Namespace</h1></header><div class="markdown"><p>Most of the components provided by Pistache live in the <code>Pistache</code> namespace.
It is thus recommended to directly import this namespace with a <code>using-declaration</code>:</p><div class="mdxCodeBlock_1XEh"><div class="codeBlockContent_1u-d"><button type="button" aria-label="Copy code to clipboard" class="copyButton_10dd">Copy</button><div tabindex="0" class="prism-code language-cpp codeBlock_3iAC"><div class="codeBlockLines_b7E3" style="color:#bfc7d5;background-color:#292d3e"><div class="token-line" style="color:#bfc7d5"><span class="token keyword" style="font-style:italic">using</span><span class="token plain"> </span><span class="token keyword" style="font-style:italic">namespace</span><span class="token plain"> Pistache</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span></div></div></div></div></div></div></article><div class="margin-vert--xl"><div class="row"><div class="col"><a href="https://github.com/facebook/docusaurus/edit/master/website/docs/namespace.md" target="_blank" rel="noreferrer noopener"><svg fill="currentColor" height="1.2em" width="1.2em" preserveAspectRatio="xMidYMid meet" viewBox="0 0 40 40" style="margin-right:0.3em;vertical-align:sub"><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></div><div class="margin-vert--lg"><nav class="pagination-nav" aria-label="Blog list page navigation"><div class="pagination-nav__item"><a class="pagination-nav__link" href="/docs/guide-http-handler"><div class="pagination-nav__sublabel">Previous</div><div class="pagination-nav__label">« Http Response</div></a></div><div class="pagination-nav__item pagination-nav__item--next"></div></nav></div></div></div><div class="col col--3"><div class="tableOfContents_3klQ"></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"><h4 class="footer__title">Docs</h4><ul class="footer__items"><li class="footer__item"><a class="footer__link-item" href="/docs/">Documentation</a></li></ul></div><div class="col footer__col"><h4 class="footer__title">Community</h4><ul class="footer__items"><li class="footer__item"><a href="https://stackoverflow.com/questions/tagged/docusaurus" target="_blank" rel="noopener noreferrer" class="footer__link-item">Stack Overflow</a></li><li class="footer__item"><a href="https://discordapp.com/invite/docusaurus" target="_blank" rel="noopener noreferrer" class="footer__link-item">Discord</a></li><li class="footer__item"><a href="https://twitter.com/docusaurus" target="_blank" rel="noopener noreferrer" class="footer__link-item">Twitter</a></li></ul></div></div><div class="text--center"><div>Copyright © 2020 Pistache. Built with Docusaurus.</div></div></div></footer></div>
<script src="/styles.95b3468f.js"></script>
<script src="/runtime~main.55b5505e.js"></script>
<script src="/main.95ce440f.js"></script>
<script src="/common.ab9d3a49.js"></script>
<script src="/2.665d4957.js"></script>
<script src="/13.c221dbe8.js"></script>
<script src="/14.f8f83444.js"></script>
<script src="/20ac7829.f0b11e5c.js"></script>
<script src="/17896441.da41daa1.js"></script>
<script src="/a0dbb6f7.5d49e106.js"></script>
</body>
</html>
\ No newline at end of file
(window.webpackJsonp=window.webpackJsonp||[]).push([[10],{66:function(e,t,n){"use strict";n.r(t),n.d(t,"frontMatter",(function(){return r})),n.d(t,"metadata",(function(){return i})),n.d(t,"rightToc",(function(){return o})),n.d(t,"default",(function(){return s}));var a=n(2),l=(n(0),n(73));const r={id:"getting-started-hello-world",title:"Hello World",sidebar_label:"Hello World"},i={unversionedId:"getting-started-hello-world",id:"getting-started-hello-world",isDocsHomePage:!1,title:"Hello World",description:"Serving requests",source:"@site/docs/getting-started-hello-world.md",permalink:"/docs/getting-started-hello-world",editUrl:"https://github.com/facebook/docusaurus/edit/master/website/docs/getting-started-hello-world.md",sidebar_label:"Hello World",sidebar:"someSidebar",previous:{title:"Installation",permalink:"/docs/"},next:{title:"Http Response",permalink:"/docs/guide-http-handler"}},o=[{value:"Include",id:"include",children:[]},{value:"Hello World",id:"hello-world",children:[]},{value:"Final touch",id:"final-touch",children:[]}],c={rightToc:o};function s({components:e,...t}){return Object(l.b)("wrapper",Object(a.a)({},c,t,{components:e,mdxType:"MDXLayout"}),Object(l.b)("h1",{id:"serving-requests"},"Serving requests"),Object(l.b)("h2",{id:"include"},"Include"),Object(l.b)("p",null,"First, let\u2019s start by including the right header"),Object(l.b)("p",null,Object(l.b)("inlineCode",{parentName:"p"},'#include "pistache/endpoint.h"')),Object(l.b)("h2",{id:"hello-world"},"Hello World"),Object(l.b)("p",null,"Requests received by Pistache are handled with an ",Object(l.b)("inlineCode",{parentName:"p"},"Http::Handler"),"."),Object(l.b)("p",null,"Let\u2019s start by defining a simple ",Object(l.b)("inlineCode",{parentName:"p"},"HelloHandler"),":"),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cpp"}),'using namespace Pistache;\n\nclass HelloHandler : public Http::Handler {\npublic:\n\n HTTP_PROTOTYPE(HelloHandler)\n\n void onRequest(const Http::Request& request, Http::ResponseWriter response) {\n response.send(Http::Code::Ok, "Hello, World");\n }\n};\n')),Object(l.b)("p",null,"Handlers must inherit the ",Object(l.b)("inlineCode",{parentName:"p"},"Http::Handler")," class and at least define the ",Object(l.b)("inlineCode",{parentName:"p"},"onRequest")," member function."),Object(l.b)("p",null,"A handler must also define a ",Object(l.b)("inlineCode",{parentName:"p"},"clone()")," member function.\nSimple handlers can use the special ",Object(l.b)("inlineCode",{parentName:"p"},"HTTP_PROTOTYPE")," macro, passing in the name of the class.\nThe macro will automatically expand to a default implementation of the ",Object(l.b)("inlineCode",{parentName:"p"},"clone()")," member function."),Object(l.b)("h2",{id:"final-touch"},"Final touch"),Object(l.b)("p",null,"After defining the handler, the server can now be started:"),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cpp"}),"int main() {\n Net::Address addr(Net::Ipv4::any(), Net::Port(9080));\n\n auto opts = Http::Endpoint::options().threads(1);\n Http::Endpoint server(addr);\n server.init(opts);\n server.setHandler(std::make_shared<HelloHandler>());\n server.serve();\n}\n")),Object(l.b)("p",null,"For simplicity, you can also use the ",Object(l.b)("inlineCode",{parentName:"p"},"listenAndServe")," helper function that will automatically create an endpoint and instantiate your handler:"),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cpp"}),'int main() {\n Http::listenAndServe<HelloHandler>("*:9080");\n}\n')),Object(l.b)("div",{className:"admonition admonition-tip alert alert--success"},Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-heading"}),Object(l.b)("h5",{parentName:"div"},Object(l.b)("span",Object(a.a)({parentName:"h5"},{className:"admonition-icon"}),Object(l.b)("svg",Object(a.a)({parentName:"span"},{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"16",viewBox:"0 0 12 16"}),Object(l.b)("path",Object(a.a)({parentName:"svg"},{fillRule:"evenodd",d:"M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"})))),"Use more serving threads")),Object(l.b)("div",Object(a.a)({parentName:"div"},{className:"admonition-content"}),Object(l.b)("p",{parentName:"div"},"By default, listenAndServe will only use 1 thread. You can tweak that by passing an Options argument to the function:"),Object(l.b)("pre",{parentName:"div"},Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-cpp"}),'auto opts = Http::Endpoint::options().threads(std::thread::hardware_concurrency());\nHttp::listenAndServe<HelloHandler>("*:9080", opts);\n')))),Object(l.b)("p",null,"And that\u2019s it, now you can fire up your favorite curl request and observe the final result:"),Object(l.b)("pre",null,Object(l.b)("code",Object(a.a)({parentName:"pre"},{className:"language-bash"}),"curl http://localhost:9080/\nHello, World\n")),Object(l.b)("p",null,"Complete code for this example can be found on GitHub: ",Object(l.b)("a",Object(a.a)({parentName:"p"},{href:"https://github.com/oktal/pistache/blob/master/examples/hello_server.cc"}),"examples/hello_server.cc")))}s.isMDXComponent=!0}}]);
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width">
<meta name="generator" content="Docusaurus v2.0.0-alpha.61">
<title data-react-helmet="true">Hello from Pistache | Pistache</title><meta data-react-helmet="true" property="og:title" content="Hello from Pistache | Pistache"><meta data-react-helmet="true" name="description" content="Description will go into a meta tag in &lt;head /&gt;"><meta data-react-helmet="true" property="og:description" content="Description will go into a meta tag in &lt;head /&gt;"><meta data-react-helmet="true" name="twitter:card" content="summary_large_image"><link data-react-helmet="true" rel="shortcut icon" href="/img/favicon.ico"><link rel="stylesheet" href="/styles.6eaf09fd.css">
<link rel="preload" href="/styles.95b3468f.js" as="script">
<link rel="preload" href="/runtime~main.55b5505e.js" as="script">
<link rel="preload" href="/main.95ce440f.js" as="script">
<link rel="preload" href="/common.ab9d3a49.js" as="script">
<link rel="preload" href="/2.665d4957.js" as="script">
<link rel="preload" href="/c4f5d8e4.2db02a7e.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">
<nav class="navbar navbar--light navbar--fixed-top"><div class="navbar__inner"><div class="navbar__items"><div aria-label="Navigation bar toggle" class="navbar__toggle" role="button" tabindex="0"><svg xmlns="http://www.w3.org/2000/svg" width="30" height="30" viewBox="0 0 30 30" role="img" focusable="false"><title>Menu</title><path stroke="currentColor" stroke-linecap="round" stroke-miterlimit="10" stroke-width="2" d="M4 7h22M4 15h22M4 23h22"></path></svg></div><a class="navbar__brand" href="/"><img class="navbar__logo" src="/img/logo.png" alt="Pistache logo"><strong class="navbar__title">Pistache</strong></a><a class="navbar__item navbar__link" href="/docs/">Docs</a></div><div class="navbar__items navbar__items--right"><div class="react-toggle react-toggle--disabled displayOnlyInLargeViewport_2aTZ"><div class="react-toggle-track"><div class="react-toggle-track-check"><span class="toggle_BsTx">🌜</span></div><div class="react-toggle-track-x"><span class="toggle_BsTx">🌞</span></div></div><div class="react-toggle-thumb"></div><input type="checkbox" disabled="" aria-label="Dark mode toggle" class="react-toggle-screenreader-only"></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 class="navbar__logo" src="/img/logo.png" alt="Pistache logo"><strong class="navbar__title">Pistache</strong></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></ul></div></div></div></nav><div class="main-wrapper"><header class="hero hero--primary heroBanner_2Ftp"><div class="container"><h1 class="hero__title">Pistache</h1><p class="hero__subtitle">Fast HTTP in modern C++</p><div class="buttons_1Wc3"><a class="button button--outline button--secondary button--lg" href="/docs/">Get Started</a></div></div></header><main><section class="features_P2SU"><div class="container"><div class="row"><div class="col col--4"><div class="text--center"><img class="featureImage_3Xqx" src="/img/easy.jpg" alt="[object Object]"></div><h3>Easy to Use</h3><p>Pistache&#x27;s API was designed to be easy to use and let you build your http server quickly</p></div><div class="col col--4"><div class="text--center"><img class="featureImage_3Xqx" src="/img/async.png" alt="[object Object]"></div><h3>Asynchronous</h3><p>Pistache&#x27;s API is fully asynchronous, meaning that the web server will not block your threads</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"><h4 class="footer__title">Docs</h4><ul class="footer__items"><li class="footer__item"><a class="footer__link-item" href="/docs/">Documentation</a></li></ul></div><div class="col footer__col"><h4 class="footer__title">Community</h4><ul class="footer__items"><li class="footer__item"><a href="https://stackoverflow.com/questions/tagged/docusaurus" target="_blank" rel="noopener noreferrer" class="footer__link-item">Stack Overflow</a></li><li class="footer__item"><a href="https://discordapp.com/invite/docusaurus" target="_blank" rel="noopener noreferrer" class="footer__link-item">Discord</a></li><li class="footer__item"><a href="https://twitter.com/docusaurus" target="_blank" rel="noopener noreferrer" class="footer__link-item">Twitter</a></li></ul></div></div><div class="text--center"><div>Copyright © 2020 Pistache. Built with Docusaurus.</div></div></div></footer></div>
<script src="/styles.95b3468f.js"></script>
<script src="/runtime~main.55b5505e.js"></script>
<script src="/main.95ce440f.js"></script>
<script src="/common.ab9d3a49.js"></script>
<script src="/2.665d4957.js"></script>
<script src="/c4f5d8e4.2db02a7e.js"></script>
</body>
</html>
\ No newline at end of file
This diff is collapsed.
/*
object-assign
(c) Sindre Sorhus
@license MIT
*/
/* NProgress, (c) 2013, 2014 Rico Sta. Cruz - http://ricostacruz.com/nprogress
* @license MIT */
/** @license React v0.19.1
* scheduler.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** @license React v16.13.1
* react-dom.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** @license React v16.13.1
* react-is.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
/** @license React v16.13.1
* react.production.min.js
*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
!function(e){function r(r){for(var n,c,u=r[0],f=r[1],i=r[2],l=0,p=[];l<u.length;l++)c=u[l],Object.prototype.hasOwnProperty.call(o,c)&&o[c]&&p.push(o[c][0]),o[c]=0;for(n in f)Object.prototype.hasOwnProperty.call(f,n)&&(e[n]=f[n]);for(d&&d(r);p.length;)p.shift()();return a.push.apply(a,i||[]),t()}function t(){for(var e,r=0;r<a.length;r++){for(var t=a[r],n=!0,c=1;c<t.length;c++){var f=t[c];0!==o[f]&&(n=!1)}n&&(a.splice(r--,1),e=u(u.s=t[0]))}return e}var n={},o={12:0},a=[];function c(e){return u.p+""+({0:"common",3:"0e0f2b52",4:"17896441",5:"20ac7829",6:"a0dbb6f7",7:"c2f6ea03",8:"c4f5d8e4",9:"ce3e42ad",10:"e4652924"}[e]||e)+"."+{0:"ab9d3a49",2:"665d4957",3:"5ec26edb",4:"da41daa1",5:"f0b11e5c",6:"5d49e106",7:"fa409731",8:"2db02a7e",9:"8ef4b1bb",10:"cbcad8f2",13:"c221dbe8",14:"f8f83444"}[e]+".js"}function u(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,u),t.l=!0,t.exports}u.e=function(e){var r=[],t=o[e];if(0!==t)if(t)r.push(t[2]);else{var n=new Promise((function(r,n){t=o[e]=[r,n]}));r.push(t[2]=n);var a,f=document.createElement("script");f.charset="utf-8",f.timeout=120,u.nc&&f.setAttribute("nonce",u.nc),f.src=c(e);var i=new Error;a=function(r){f.onerror=f.onload=null,clearTimeout(l);var t=o[e];if(0!==t){if(t){var n=r&&("load"===r.type?"missing":r.type),a=r&&r.target&&r.target.src;i.message="Loading chunk "+e+" failed.\n("+n+": "+a+")",i.name="ChunkLoadError",i.type=n,i.request=a,t[1](i)}o[e]=void 0}};var l=setTimeout((function(){a({type:"timeout",target:f})}),12e4);f.onerror=f.onload=a,document.head.appendChild(f)}return Promise.all(r)},u.m=e,u.c=n,u.d=function(e,r,t){u.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},u.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},u.t=function(e,r){if(1&r&&(e=u(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(u.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)u.d(t,n,function(r){return e[r]}.bind(null,n));return t},u.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return u.d(r,"a",r),r},u.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},u.p="/",u.gca=function(e){return c(e={17896441:"4",common:"0","0e0f2b52":"3","20ac7829":"5",a0dbb6f7:"6",c2f6ea03:"7",c4f5d8e4:"8",ce3e42ad:"9",e4652924:"10"}[e]||e)},u.oe=function(e){throw console.error(e),e};var f=window.webpackJsonp=window.webpackJsonp||[],i=f.push.bind(f);f.push=r,f=f.slice();for(var l=0;l<f.length;l++)r(f[l]);var d=i;t()}([]);
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:news="http://www.google.com/schemas/sitemap-news/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:mobile="http://www.google.com/schemas/sitemap-mobile/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:video="http://www.google.com/schemas/sitemap-video/1.1"><url><loc>http://pistache.io/</loc><changefreq>weekly</changefreq><priority>0.5</priority></url><url><loc>http://pistache.io/docs/</loc><changefreq>weekly</changefreq><priority>0.5</priority></url><url><loc>http://pistache.io/docs/getting-started-hello-world</loc><changefreq>weekly</changefreq><priority>0.5</priority></url><url><loc>http://pistache.io/docs/guide-http-handler</loc><changefreq>weekly</changefreq><priority>0.5</priority></url><url><loc>http://pistache.io/docs/mdx</loc><changefreq>weekly</changefreq><priority>0.5</priority></url><url><loc>http://pistache.io/docs/namespace</loc><changefreq>weekly</changefreq><priority>0.5</priority></url></urlset>
\ No newline at end of file
This diff is collapsed.
(window.webpackJsonp=window.webpackJsonp||[]).push([[1],[,,,,,,,,,,,,,,,function(e,n,o){},,,,,,,,,,,,,,,,,,,,,,,,function(e,n,o){},,,,function(e,n,o){},function(e,n,o){},,,function(e,n,o){e.exports={announcementBar:"announcementBar_1l0Z",announcementBarClose:"announcementBarClose_21wD",announcementBarContent:"announcementBarContent_1xni"}},function(e,n,o){e.exports={toggle:"toggle_BsTx"}},function(e,n,o){e.exports={displayOnlyInLargeViewport:"displayOnlyInLargeViewport_2aTZ",hideLogoText:"hideLogoText_GP-Q",navbarHideable:"navbarHideable_3046",navbarHidden:"navbarHidden_1Uo_"}},function(e,n,o){e.exports={footerLogoLink:"footerLogoLink_1zJy"}},function(e,n,o){},,function(e,n,o){e.exports={docTitle:"docTitle_1Lrw",docItemContainer:"docItemContainer_3QWW",docItemCol:"docItemCol_2ASc",docItemWrapper:"docItemWrapper_1EkI",tableOfContents:"tableOfContents_3klQ",docLastUpdatedAt:"docLastUpdatedAt_217_"}},function(e,n,o){e.exports={sidebar:"sidebar_2urC",sidebarWithHideableNavbar:"sidebarWithHideableNavbar_2IoJ",sidebarLogo:"sidebarLogo_Snse",menu:"menu_5FrY",menuLinkText:"menuLinkText_2zSB",menuWithAnnouncementBar:"menuWithAnnouncementBar_18ic",sidebarMenuIcon:"sidebarMenuIcon_Dm3K",sidebarMenuCloseIcon:"sidebarMenuCloseIcon_hir9"}},function(e,n,o){e.exports={codeBlockContent:"codeBlockContent_1u-d",codeBlockTitle:"codeBlockTitle_3nn1",codeBlock:"codeBlock_3iAC",codeBlockWithTitle:"codeBlockWithTitle_3QsD",copyButton:"copyButton_10dd",codeBlockLines:"codeBlockLines_b7E3"}},function(e,n,o){},function(e,n,o){e.exports={enhancedAnchor:"enhancedAnchor_2cZh"}},function(e,n,o){e.exports={mdxCodeBlock:"mdxCodeBlock_1XEh"}},function(e,n,o){e.exports={docPage:"docPage_2gpo",docSidebarContainer:"docSidebarContainer_3_JD",docMainContainer:"docMainContainer_3EyW"}},,,,,function(e,n,o){e.exports={heroBanner:"heroBanner_2Ftp",buttons:"buttons_1Wc3",features:"features_P2SU",featureImage:"featureImage_3Xqx"}}]]);
\ 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