Pistache is a web framework written in Modern C++ that focuses on performance and provides an elegant
and asynchronous API.
Pistache does not support Windows yet.
To download the latest available release, clone the repository over github.
git clone https://github.com/oktal/pistache.git
Then, init the submodules:
git submodule update --init
Now, compile the sources:
Optionally, you can also run the tests:
async_test can take some time before completing.
And that’s it, now you can start playing with your newly installed
First, let’s start by including the right header
Requests received by
Pistache are handled with an
Let’s start by defining a simple
Handlers must inherit the
Http::Handler class and at least define the
onRequest member function.
They must also define a
clone() member function. Simple handlers can use the special
macro, passing in the name of the class. The macro will take care of defining the
clone() member function
After defining the handler, the server can now be started:
For simplicity, you can also use the special
listenAndServe function that will automatically create an
endpoint and instantiate your handler:
Note that by default,
listenAndServe will only use 1 thread. You can tweak that by passing an
to the function:
And that’s it, now you can fire up your favorite curl request and observe the final result:
Complete code for this example can be found on Github: examples/hello_server.cc