All Projects → Stiffstream → Restinio

Stiffstream / Restinio

Licence: other
Cross-platform, efficient, customizable, and robust asynchronous HTTP/WebSocket server C++14 library with the right balance between performance and ease of use

Programming Languages

cpp
1120 projects
cplusplus
227 projects
cpp14
131 projects

Projects that are alternatives of or similar to Restinio

Cowboy
Small, fast, modern HTTP server for Erlang/OTP.
Stars: ✭ 6,533 (+841.35%)
Mutual labels:  rest, websockets, https, http-server
Simple Web Server
A very simple, fast, multithreaded, platform independent HTTP and HTTPS server and client library implemented using C++11 and Boost.Asio. Created to be an easy way to make REST resources available from C++ applications.
Stars: ✭ 2,261 (+225.79%)
Mutual labels:  rest, library, asio, https
Gun
HTTP/1.1, HTTP/2 and Websocket client for Erlang/OTP.
Stars: ✭ 710 (+2.31%)
Mutual labels:  rest, websockets, https
Jetty.project
Eclipse Jetty® - Web Container & Clients - supports HTTP/2, HTTP/1.1, HTTP/1.0, websocket, servlets, and more
Stars: ✭ 3,260 (+369.74%)
Mutual labels:  websockets, https, http-server
Beast
HTTP and WebSocket built on Boost.Asio in C++11
Stars: ✭ 3,241 (+367%)
Mutual labels:  websockets, asio, http-server
Farwest
Framework for building RESTful HATEOAS-driven applications.
Stars: ✭ 18 (-97.41%)
Mutual labels:  rest, https, http-server
Watsonwebserver
Watson is the fastest, easiest way to build scalable RESTful web servers and services in C#.
Stars: ✭ 125 (-81.99%)
Mutual labels:  rest, https, http-server
node-jsonrpc2
JSON-RPC 2.0 server and client library, with HTTP (with Websocket support) and TCP endpoints
Stars: ✭ 103 (-85.16%)
Mutual labels:  https, websockets, http-server
Microwebsrv2
The last Micro Web Server for IoTs (MicroPython) or large servers (CPython), that supports WebSockets, routes, template engine and with really optimized architecture (mem allocations, async I/Os). Ready for ESP32, STM32 on Pyboard, Pycom's chipsets (WiPy, LoPy, ...). Robust, efficient and documented!
Stars: ✭ 295 (-57.49%)
Mutual labels:  websockets, https
Pode
Pode is a Cross-Platform PowerShell web framework for creating REST APIs, Web Sites, and TCP/SMTP servers
Stars: ✭ 329 (-52.59%)
Mutual labels:  rest, https
Libevhtp
Create extremely-fast and secure embedded HTTP servers with ease.
Stars: ✭ 363 (-47.69%)
Mutual labels:  library, https
Purest
REST API Client Library
Stars: ✭ 448 (-35.45%)
Mutual labels:  rest, https
Prdownloader
PRDownloader - A file downloader library for Android with pause and resume support
Stars: ✭ 2,947 (+324.64%)
Mutual labels:  library, https
Restc Cpp
Modern C++ REST Client library
Stars: ✭ 371 (-46.54%)
Mutual labels:  rest, asio
Curl
A command line tool and library for transferring data with URL syntax, supporting DICT, FILE, FTP, FTPS, GOPHER, GOPHERS, HTTP, HTTPS, IMAP, IMAPS, LDAP, LDAPS, MQTT, POP3, POP3S, RTMP, RTMPS, RTSP, SCP, SFTP, SMB, SMBS, SMTP, SMTPS, TELNET and TFTP. libcurl offers a myriad of powerful features
Stars: ✭ 22,875 (+3196.11%)
Mutual labels:  library, https
Cppwebframework
​The C++ Web Framework (CWF) is a MVC web framework, Open Source, under MIT License, using C++ with Qt to be used in the development of web applications.
Stars: ✭ 348 (-49.86%)
Mutual labels:  rest, http-server
Http
Host These Things Please - a basic http server for hosting a folder fast and simply
Stars: ✭ 275 (-60.37%)
Mutual labels:  https, http-server
Diet
A tiny, fast and modular node.js web framework. Good for making fast & scalable apps and apis.
Stars: ✭ 394 (-43.23%)
Mutual labels:  rest, http-server
Http
Event-driven, streaming HTTP client and server implementation for ReactPHP.
Stars: ✭ 507 (-26.95%)
Mutual labels:  https, http-server
Pmhttp
Swift/Obj-C HTTP framework with a focus on REST and JSON
Stars: ✭ 509 (-26.66%)
Mutual labels:  rest, library

What Is RESTinio?

RESTinio is a header-only C++14 library that gives you an embedded HTTP/Websocket server. It is based on standalone version of ASIO and targeted primarily for asynchronous processing of HTTP-requests. Since v.0.4.1 Boost::ASIO (1.66 or higher) is also supported (see notes on building with Boost::ASIO).

A Very Basic Example Of RESTinio

Consider the task of writing a C++ application that must support some REST API, RESTinio represents our solution for that task. Currently it is in stable beta state. Lets see how it feels like in the simplest case:

#include <restinio/all.hpp>
int main()
{
    restinio::run(
        restinio::on_this_thread()
        .port(8080)
        .address("localhost")
        .request_handler([](auto req) {
            return req->create_response().set_body("Hello, World!").done();
        }));
    return 0;
}

Server runs on the main thread, and respond to all requests with hello-world message. Of course you've got an access to the structure of a given HTTP request, so you can apply a complex logic for handling requests.

Features

  • Async request handling. Cannot get the response data immediately? That's ok, store request handle somewhere and/or pass it to another execution context and get back to it when the data is ready.
  • HTTP pipelining. Works well with async request handling. It might increase your server throughput dramatically.
  • Timeout control. RESTinio can take care of bad connection that are like: send "GET /" and then just stuck.
  • Response builders. Need chunked-encoded body - then RESTinio has a special response builder for you (obviously it is not the only builder).
  • ExpressJS-like request routing (see an example below).
  • An experimental typesafe request router that allows avoiding problems of ExpressJS-like router with help of static checks from C++ compiler.
  • A possibility to chain several request-handlers (somewhat similar to ExpressJS's middleware).
  • Working with query string parameters.
  • Several ready-to-use helpers for working with HTTP headers (for example, the support for HTTP headers related to file uploading).
  • Supports sending files and its parts (with sendfile on linux/unix and TransmitFile on windows).
  • Supports compression (deflate, gzip).
  • Supports TLS (HTTPS).
  • Basic websocket support. Simply restinio::websocket::basic::upgrade() the request handle and start websocket session on a corresponding connection.
  • Can run on external asio::io_context. RESTinio is separated from execution context.
  • Some tune options. One can set acceptor and socket options. When running RESTinio on a pool of threads connections can be accepted in parallel.

Enhanced Example With Express Router

#include <restinio/all.hpp>

using namespace restinio;

template<typename T>
std::ostream & operator<<(std::ostream & to, const optional_t<T> & v) {
    if(v) to << *v;
    return to;
}

int main() {
    // Create express router for our service.
    auto router = std::make_unique<router::express_router_t<>>();
    router->http_get(
            R"(/data/meter/:meter_id(\d+))",
            [](auto req, auto params) {
                const auto qp = parse_query(req->header().query());
                return req->create_response()
                        .set_body(
                                fmt::format("meter_id={} (year={}/mon={}/day={})",
                                        cast_to<int>(params["meter_id"]),
                                        opt_value<int>(qp, "year"),
                                        opt_value<int>(qp, "mon"),
                                        opt_value<int>(qp, "day")))
                        .done();
            });

    router->non_matched_request_handler(
            [](auto req){
                return req->create_response(restinio::status_not_found()).connection_close().done();
            });

    // Launching a server with custom traits.
    struct my_server_traits : public default_single_thread_traits_t {
        using request_handler_t = restinio::router::express_router_t<>;
    };

    restinio::run(
            restinio::on_this_thread<my_server_traits>()
                    .address("localhost")
                    .request_handler(std::move(router)));

    return 0;
}

License

RESTinio is distributed under BSD-3-CLAUSE license.

How To Use It?

The full documentation for RESTinio can be found here.

More

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].