Corvusoft's Restbed framework brings asynchronous RESTful functionality to C++14 applications.

Overview

Restbed Unix Build Status Windows Build Status


Restbed is a comprehensive and consistent programming model for building applications that require seamless and secure communication over HTTP, with the ability to model a range of business processes, designed to target mobile, tablet, desktop and embedded production environments.

It's akin to embedding NGINX into your companies own product line. -- Solutions Architect, Bellrock Technology

Features

Feature Description
WebSockets Full-duplex communication channels over a single TCP connection.
Server-Sent Events Server-Sent Events enables efficient server-to-client streaming of text-based event data—e.g., real-time notifications or updates generated on the server.
Comet Long polling model to allow long-held HTTP requests for pushing data from the server to client.
SSL/TLS Secure over the wire communication allowing you to transmit private data online.
Session Management Create custom HTTP session persistence and management logic.
HTTP Pipelining A technique allowing multiple HTTP requests to be sent on a single TCP connection without waiting for the corresponding responses.
Path Parameters Annotate URIs with custom path parameters such as resource keys, revisions, etc...
Query Parameters Automated query parameter parsing.
Header Filters Filter incoming HTTP requests by headers.
Logging Customise how and where log entries are created.
Multi-Path Resources Give a resource multiple paths for improved readability.
Customisable Methods Add your own custom HTTP methods.
Compression Adaptability to address any form of compression GZip, Deflate, etc...
Encoding Adaptability to address any form of encoding UTF-32, ASCII, etc...
Rules Engine Reduce complexity by processing incoming requests with readable units of code.
HTTP/HTTPS Built in client capabilities with optional SSL peer certificate verification. Deprecated
IPv4/IPv6 Internet Protocol Version 4/6 Network Support.
Architecture Asynchronous single or multi-threaded architecture, capable of addressing the C10K problem.
Converters Built-in Path, Query, and Header conversions for primary data-types.
Authentication Separate Service and/or Resource level authentication.
Error Handling Separate Service and/or Resource level error handling.
Address Binding Bind HTTP and/or HTTPS services to separate IP addresses.
Signal Handling Capture OS generated process signals.
Documentation High-quality documentation covering the architecture and API.
Compliance Flexibility to address HTTP 1.0/1.1+ compliance.
Mature Secure, Stable, and extensively tested since 2013.
Community Active, vibrant and energetic open source community.
Support Commercial support is available from Corvusoft.

Example

#include <memory>
#include <cstdlib>
#include <restbed>

using namespace std;
using namespace restbed;

void post_method_handler( const shared_ptr< Session > session )
{
    const auto request = session->get_request( );

    int content_length = request->get_header( "Content-Length", 0 );

    session->fetch( content_length, [ ]( const shared_ptr< Session > session, const Bytes & body )
    {
        fprintf( stdout, "%.*s\n", ( int ) body.size( ), body.data( ) );
        session->close( OK, "Hello, World!", { { "Content-Length", "13" } } );
    } );
}

int main( const int, const char** )
{
    auto resource = make_shared< Resource >( );
    resource->set_path( "/resource" );
    resource->set_method_handler( "POST", post_method_handler );

    auto settings = make_shared< Settings >( );
    settings->set_port( 1984 );
    settings->set_default_header( "Connection", "close" );

    Service service;
    service.publish( resource );
    service.start( settings );

    return EXIT_SUCCESS;
}

More in-depth examples can be found here. To see Restbed used in anger, please visit Corvusoft's RestQ project.

License

© 2013-2020 Corvusoft Limited, United Kingdom. All rights reserved.

The Restbed framework is dual licensed; See LICENSE for full details.

Support

Please contact [email protected], for support and licensing options including bespoke software development, testing, design consultation, training, mentoring and code review.

Please submit all enhancements, proposals, and defects via the issue tracker; Alternatively ask a question on StackOverflow tagged #restbed.

Build

git clone --recursive https://github.com/corvusoft/restbed.git
mkdir restbed/build
cd restbed/build
cmake [-DBUILD_SSL=NO] [-DBUILD_TESTS=NO] ..
make install
make test

You will now find all required components installed in the distribution sub-folder.

Building with external libraries

If you wish to build with external libraries (OpenSSL, ASIO).

git clone https://github.com/corvusoft/restbed.git
mkdir restbed/build
cd restbed/build
cmake [-DBUILD_SSL=NO] [-DBUILD_TESTS=NO] ..
make install
make test

Windows Build Instructions

For Microsoft Visual Studio instructions please see feature #17.

Building restbed - Using vcpkg

You can download and install restbed using the vcpkg dependency manager:

git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
./vcpkg integrate install
./vcpkg install restbed

The restbed port in vcpkg is kept up to date by Microsoft team members and community contributors. If the version is out of date, please create an issue or pull request on the vcpkg repository.

Documentation

This codebase is intended to be as self documenting as possible. We have supplied many examples and test suites to help aid developers.

You can locate the latest design and API documentation here.

Minimum Requirements

Resource Requirement
Compiler C++14 compliant or above
OS BSD, Linux, Mac OSX, Windows, Raspbian

Road Map

Milestone Feature Status
0.0 Asynchronous HTTP Service complete
1.0 HTTP 1.0 Compliance complete
2.0 HTTP 1.1 Compliance complete
2.5 Secure Socket Layer complete
2.5 Simultaneous Network Ports (HTTP/HTTPS) complete
3.0 Rules Engine complete
3.5 Schedule Tasks on Service run-loop complete
3.5 Multi-Threaded service capability complete
3.5 Bind Service to specific Address complete
3.5 Session Management complete
4.0 HTTP Client complete
4.0 Signal Handling complete
4.5 API Documentation complete
4.5 Web Sockets complete
5.0 Client-side SSL certificates development
5.0 Resource Caching development
5.0 Runtime Modifications development
5.0 HTTP 2 compliance development
5.0 Refactor, Reduce, Reuse pending

Contact

Method Description
Twitter Tweet us your questions & feature requests.
[email protected] Support related queries.
[email protected] Sale related queries.
Comments
  • CMakeList.txt typos for ssl

    CMakeList.txt typos for ssl

    In the current master branch (4.8) there are typos in the CMakeList.txt:

    cmake -DBUILD_SSL=YES ..
    
    CMake Error at cmake/Findopenssl.cmake:22 (message):
      Failed to locate OpenSSL dependency.  see restbed/dependency/openssl
    Call Stack (most recent call first):
      CMakeLists.txt:60 (find_package)
    

    Fix:

    -- find_package( openssl REQUIRED ) ++ find_package( OpenSSL REQUIRED )

    When this is fixed there are a few other typos:

    cmake -DBUILD_SSL=YES ..
    
    
    crypto_LIBRARY_STATIC
        linked by target "restbed-static" in directory /srv/rest/restbed
    
    ssl_LIBRARY_STATIC
        linked by target "restbed-static" in directory /srv/rest/restbed
    

    Fix (several instances in the file):

    -- crypto_LIBRARY_STATIC ++ CRYPTO_LIBRARY_STATIC

    -- ssl_LIBRARY_STATIC ++ SSL_LIBRARY_STATIC

    opened by lilltiger 0
  • ask for help:: How to send the main body content multiple times?

    ask for help:: How to send the main body content multiple times?

    For example, if I want to send a file to the client, each time I call the read function, I will read 1024 bytes from the file. How to send it only once without using Bytes, but send it every read. Looking forward to your help.

    opened by gaowanlu 1
  • Example/HTTPS_SERVICE error

    Example/HTTPS_SERVICE error

    Hi, I used the vcpkg and installed the library of the restbed[openssl]. My OS is Windows 10 x64 and I use Visual Studio 2019 Community Edition. I compile (Debug, x86) the example/HTTPS_SERVICE and when I run it, I get an error with code 3. Could you tell me what I did wrong?

    opened by valendovsky 0
  • Only export restbed symbols when building as a shared library + fix MinGW build

    Only export restbed symbols when building as a shared library + fix MinGW build

    Fixes #531 by:

    • only exporting the restbed symbols when building restbed as a shared library. On Windows, when linking to a static restbed, you now need to add -DRESTBED_STATIC to the compiler.
    • When installing, also install the binary component of a shared library. This is the .dll on Windows.
    • Fix issues when building restbed using MinGW@Linux. In addition to gcc@Linux, I used this toolchain to verify the correct symbol visibility of restbed's users.

    Fixes https://github.com/Corvusoft/restbed/issues/496 too

    opened by madebr 0
  • Cannot buid a static Windows restbed library without export any symbol

    Cannot buid a static Windows restbed library without export any symbol

    On current master, you cannot build restbed without exporting any restbed symbol. This is because __declspec(dllimport) or __declspec(dllexport) is always prepended.

    https://github.com/Corvusoft/restbed/blob/0c99284fba4f37a89de24972e48b8154abc5dc75/source/corvusoft/restbed/request.hpp#L24-L32

    There is no path to avoid the __declspec or the __attribute__((visibility ("default"))).

    opened by madebr 0
  • MINSIGSTKSZ error during building

    MINSIGSTKSZ error during building

    in the installation phase called "Building CXX object test/unit/CMakeFiles/uri_unit_test_suite.dir/source/uri_suite.cpp.o" i have this error :

    In file included from /usr/include/signal.h:328,
                     from /home/mattia/Sviluppo/restbed/dependency/catch/single_include/catch2/catch.hpp:7955,
                     from /home/mattia/Sviluppo/restbed/test/unit/source/uri_suite.cpp:10:
    /home/mattia/Sviluppo/restbed/dependency/catch/single_include/catch2/catch.hpp:10735:58: error: call to non-‘constexpr’ function ‘long int sysconf(int)’
    10735 |     static constexpr std::size_t sigStackSize = 32768 >= MINSIGSTKSZ ? 32768 : MINSIGSTKSZ;
          |                                                          ^~~~~~~~~~~
    In file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24:
    /usr/include/unistd.h:640:17: note: ‘long int sysconf(int)’ declared here
      640 | extern long int sysconf (int __name) __THROW;
          |                 ^~~~~~~
    /home/mattia/Sviluppo/restbed/dependency/catch/single_include/catch2/catch.hpp:10794:45: error: size of array ‘altStackMem’ is not an integral constant-expression
    10794 |     char FatalConditionHandler::altStackMem[sigStackSize] = {};
          |                                             ^~~~~~~~~~~~
    make[2]: *** [test/unit/CMakeFiles/uri_unit_test_suite.dir/build.make:76: test/unit/CMakeFiles/uri_unit_test_suite.dir/source/uri_suite.cpp.o] Error 1
    make[1]: *** [CMakeFiles/Makefile2:432: test/unit/CMakeFiles/uri_unit_test_suite.dir/all] Error 2
    make: *** [Makefile:146: all] Error 2
    

    can anyone help me? i'm using Ubuntu 22.04.1 LTS and gcc/g++ 12

    opened by mattiadido95 1
Releases(4.8)
Owner
Corvusoft
B2B Software/Hardware Development
Corvusoft
Fast and easy C++ RESTful WebServices framework

ngrest ngrest is a simple C++ REST framework. It has small footprint, fast and very easy in use. ngrest allow you to deploy C++ RESTful webservices un

Dmitry 450 Dec 29, 2022
ORM for consuming RESTful APIs in C++

restful_mapper ORM for consuming RESTful APIs in C++ Introduction restful_mapper connects business objects and Representational State Transfer (REST)

Logan Raarup 80 Dec 16, 2022
A C++ async HTTP client library to use in asynchronous applications while communicating with REST services.

libashttp An asynchronous HTTP library using Boost.ASIO as the backend. This project is licensed under: Usage Here is a example usage which is taken f

Tolga Hoşgör 53 Dec 17, 2022
An asynchronous web framework for C++ built on top of Qt

!!! I can no longer maintain this project. If you're interessed, please contact me and I can move the projetct to you !!! Tufão - an asynchronous web

Vinícius dos Santos Oliveira 556 Dec 28, 2022
Enabling services on your device 81 Jan 6, 2023
LibVNCServer/LibVNCClient are cross-platform C libraries that allow you to easily implement VNC server or client functionality in your program.

LibVNCServer: A library for easy implementation of a VNC server. Copyright (C) 2001-2003 Johannes E. Schindelin If you already used LibVNCServer, you

null 888 Dec 30, 2022
Zyre - an open-source framework for proximity-based peer-to-peer applications

Zyre - Local Area Clustering for Peer-to-Peer Applications Linux & MacOSX Windows Contents Overview Scope and Goals Ownership and License Using Zyre B

The ZeroMQ project 813 Jan 3, 2023
The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.

Welcome! The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design

Microsoft 7.2k Dec 30, 2022
Cross-platform, efficient, customizable, and robust asynchronous HTTP/WebSocket server C++14 library with the right balance between performance and ease of use

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

Stiffstream 924 Jan 6, 2023
A C library for asynchronous DNS requests

c-ares This is c-ares, an asynchronous resolver library. It is intended for applications which need to perform DNS queries without blocking, or need t

c-ares 1.5k Jan 3, 2023
Ultra fast and low latency asynchronous socket server & client C++ library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and 10K connections problem solution

CppServer Ultra fast and low latency asynchronous socket server & client C++ library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and

Ivan Shynkarenka 958 Jan 3, 2023
Asynchronous networking for C

Overview Dyad.c is an asynchronous networking library which aims to be lightweight, portable and easy to use. It can be used both to create small stan

null 1.4k Dec 28, 2022
C++ Parallel Computing and Asynchronous Networking Engine

As Sogou`s C++ server engine, Sogou C++ Workflow supports almost all back-end C++ online services of Sogou, including all search services, cloud input method,online advertisements, etc., handling more than 10 billion requests every day

Sogou Open Source 9.7k Jan 5, 2023
Asynchronous gRPC with Boost.Asio executors

asio-grpc This library provides an implementation of boost::asio::execution_context that dispatches work to a grpc::CompletionQueue. Making it possibl

Dennis 180 Dec 31, 2022
A Lightweight and fully asynchronous WebSocket client library based on libev

libuwsc(中文) A Lightweight and fully asynchronous WebSocket client library based on libev for Embedded Linux. And provide Lua-binding. Why should I cho

Jianhui Zhao 285 Dec 24, 2022
Asynchronous TCP Library for STM32H7-based Portenta_H7 using mbed_portenta core.

Asynchronous TCP Library for STM32H7-based Portenta_H7 using mbed_portenta core. This library is the base for future and more advanced Async libraries, such as AsyncWebServer, AsyncHTTPRequest, AsyncHTTPSRequest

Khoi Hoang 3 Dec 29, 2022
Asynchronous SSL TCP Library for ESP32.

Asynchronous SSL TCP Library for ESP32. This library is the base for future and more advanced Async SSL libraries, such as AsyncSSLWebServer, AsyncHTTPSRequest

Khoi Hoang 12 Dec 29, 2022
Packio - An asynchronous msgpack-RPC and JSON-RPC library built on top of Boost.Asio.

Header-only | JSON-RPC | msgpack-RPC | asio | coroutines This library requires C++17 and is designed as an extension to boost.asio. It will let you bu

Quentin Chateau 58 Dec 26, 2022
Asynchronous, Header-only C++ HTTP-over-(TCP|UNIX Socket|STDIO) Library

CXXHTTP A C++ library implementing an asynchronous HTTP server and client. To clone this library, make sure you also clone the submodules. The --recur

null 25 Mar 19, 2021