fitoria is a modern C++20, cross-platform web framework.
The library is experimental and still under development, not recommended for production use.
- Ease to use: APIs are designed based on C++20 coroutine and highly integrated with
optional
andexpected
to provide better error handling mechanisms - Cross-platform, write once and run across Windows, Linux and MacOS
- Support HTTP/1.1
- Support SSL up to TLS 1.3
- Support Unix Domain Socket
- Support WebSocket
More details can be found in the documentation
The following example demonstrates how to create a simple http_server
and attach handlers to it. (Getting Started Example)
#include <fitoria/web.hpp>
using namespace fitoria;
using namespace fitoria::web;
auto hello_world() -> awaitable<response>
{
co_return response::ok()
.set_header(http::field::content_type, mime::text_plain())
.set_body("Hello World!");
}
auto echo(std::string body) -> awaitable<response>
{
co_return response::ok()
.set_header(http::field::content_type, mime::text_plain())
.set_body(body);
}
int main()
{
auto ioc = net::io_context();
auto server = http_server::builder(ioc)
.serve(route::get<"/">(hello_world))
.serve(route::post<"/echo">(echo))
.build();
server.bind("127.0.0.1", 8080);
ioc.run();
}
Platform
- Linux
- Windows
- MacOS
Compiler (C++20)
- GCC 13
- MSVC 17 2022
- Clang 15
Dependencies
Library | Minimum Version | Note | |
---|---|---|---|
boost::asio |
1.85.0 |
required | |
boost::beast |
1.85.0 |
required | |
boost::json |
1.85.0 |
required | |
boost::url |
1.85.0 |
required | |
boost::pfr |
1.85.0 |
required | |
fmt |
10.0.0 |
required | |
zlib |
optional | ||
brotli |
optional | ||
openssl |
optional | ||
doctest |
optional | required when FITORIA_BUILD_TESTS=ON . |
|
boost::scope |
1.85.0 |
optional | required when FITORIA_BUILD_TESTS=ON . |
boost::uuid |
1.85.0 |
optional | required when FITORIA_BUILD_EXAMPLES=ON . |
CMake
Option | Description | Value | Default |
---|---|---|---|
FITORIA_BUILD_EXAMPLES | Build examples | ON/OFF | OFF |
FITORIA_BUILD_TESTS | Build tests | ON/OFF | OFF |
FITORIA_DISABLE_OPENSSL | Do not enable OpenSSL dependent features | ON/OFF | OFF |
FITORIA_DISABLE_ZLIB | Do not enable ZLIB dependent features | ON/OFF | OFF |
FITORIA_DISABLE_BROTLI | Do not enable Brotli dependent features | ON/OFF | OFF |
FITORIA_DISABLE_LIBURING | Do not enable liburing | ON/OFF | OFF |
FITORIA_ENABLE_CODECOV | Enable code coverage build | ON/OFF | OFF |
FITORIA_ENABLE_CLANG_TIDY | Enable clang-tidy check | ON/OFF | OFF |
FITORIA_ENABLE_ADDRESS_SANITIZER | Compile with -fsanitize=address |
ON/OFF | OFF |
git clone https://github.com/Ramirisu/fitoria.git
cd fitoria/
cmake -B build -DFITORIA_BUILD_EXAMPLES=ON -DFITORIA_BUILD_TESTS=ON
cmake --build build
cd build && ctest && cd ..
This project is distributed under the Boost Software License 1.0.