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.
Issues
  • Is there any Websocket client example?

    Is there any Websocket client example?

    Hi. Is there any Websocket client example? I only find Websocket server example but not find any websocket client example (incluing websocket security) with restbed.

    opened by fan-chao 0
  • Unable to generate restbedConfig.cmake

    Unable to generate restbedConfig.cmake

    I'm trying to build restbed using cmake and I got success in it. But cmake is not generating cmake files for Config and Target so that other cmake based applications will be able to find restbed libs and header files.

    opened by navyverma 0
  • enhance documentation that session on error handler could point to null

    enhance documentation that session on error handler could point to null

    We are using the tag 4.8 of the restbed source code.

    We are using the following "simple" error handler:

        restbed::Service service;
    
        service.set_error_handler([](const int                                tbd,
                                     const std::exception&                    exc,
                                     const std::shared_ptr<restbed::Session>& session) {
            if (session->is_open())
            {
                session->close(restbed::INTERNAL_SERVER_ERROR);
            }
            const std::type_info& typeInfo = typeid(exc);
            std::cerr << "ERROR HANDLER: tbd=" << tbd << ", exc.what: " << exc.what()
                      << ", exc type info name: " << typeInfo.name() << std::endl;
        });
    

    I can reproduce errors by reload the pages while the loading is in progress (so the cause seems to be breaking the client connection while data is transmitted).

    The call to session->is_open() seems to be "dangerous". As sometimes it crashes by SIGSEGV

    Here a stack trace:

    x76d349d4 in restbed::Session::is_open() const () from /usr/lib/librestbed.so.4
    (gdb) bt  
    #0  0x76d349d4 in restbed::Session::is_open() const () from /usr/lib/librestbed.so.4
    #1  0x54ab8702 in <lambda(int, const std::exception&, const std::shared_ptr<restbed::Session>&)>::operator() (
        session=..., exc=..., tbd=408, __closure=<optimized out>)
        at /opt/yocto/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/include/c++/9.3.0/bits/shared_ptr_base.h:1309
    #2  std::_Function_handler<void(int, const std::exception&, std::shared_ptr<restbed::Session>), https(const AppSrvConfig&, const std::shared_ptr<IpcHandlerInterface>&)::<lambda(int, const std::exception&, const std::shared_ptr<restbed::Session>&)> >::_M_invoke(const std::_Any_data &, int &&, const std::exception &, std::shared_ptr<restbed::Session> &&) (__functor=..., __args#0=<optimized out>, __args#1=..., __args#2=...)
        at /opt/yocto/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/include/c++/9.3.0/bits/std_function.h:300
    #3  0x76d1b99e in restbed::detail::SocketImpl::connection_timeout_handler(std::shared_ptr<restbed::detail::SocketImpl>, std::error_code const&) () from /usr/lib/librestbed.so.4
    #4  0x76d1f61e in void std::__invoke_impl<void, void (restbed::detail::SocketImpl::*&)(std::shared_ptr<restbed::detail::SocketImpl>, std::error_code const&), restbed::detail::SocketImpl*&, std::shared_ptr<restbed::detail::SocketImpl>&, std::error_code const&>(std::__invoke_memfun_deref, void (restbed::detail::SocketImpl::*&)(std::shared_ptr<restbed::detail::SocketImpl>, std::error_code const&), restbed::detail::SocketImpl*&, std::shared_ptr<restbed::detail::SocketImpl>&, std::error_code const&) () from /usr/lib/librestbed.so.4
    #5  0x76d1f9f4 in void asio::detail::strand_service::dispatch<asio::detail::binder1<std::_Bind<void (restbed::detail::SocketImpl::*(restbed::detail::SocketImpl*, std::shared_ptr<restbed::detail::SocketImpl>, std::_Placeholder<1>))(std::shared_ptr<restbed::detail::SocketImpl>, std::error_code const&)>, std::error_code> >(asio::detail::strand_service::strand_impl*&, asio::detail::binder1<std::_Bind<void (restbed::detail::SocketImpl::*(restbed::detail::SocketImpl*, std::shared_ptr<restbed::detail::SocketImpl>, std::_Placeholder<1>))(std::shared_ptr<restbed::detail::SocketImpl>, std::error_code const&)>, std::error_code>&) () from /usr/lib/librestbed.so.4
    #6  0x76d202e4 in asio::detail::completion_handler<asio::detail::rewrapped_handler<asio::detail::binder1<asio::detail::wrapped_handler<asio::io_context::strand, std::_Bind<void (restbed::detail::SocketImpl::*(restbed::detail::SocketImpl*, std::shared_ptr<restbed::detail::SocketImpl>, std::_Placeholder<1>))(std::shared_ptr<restbed::detail::SocketImpl>, std::error_code const&)>, asio::detail::is_continuation_if_running>, std::error_code>, std::_Bind<void (restbed::detail::SocketImpl::*(restbed::detail::SocketImpl*, std::shared_ptr<restbed::detail::SocketImpl>, std::_Placeholder<1>))(std::shared_ptr<restbed::detail::SocketImpl>, std::error_code const&)> >, asio::io_context::basic_executor_type<std::allocator<void>, 0u> >::do_complete(void*, asio::detail::scheduler_operation*, std::error_code const&, unsigned int) () from /usr/lib/librestbed.so.4
    #7  0x76d1d4c0 in ?? () from /usr/lib/librestbed.so.4
    #8  0x76d1fbda in void asio::detail::strand_service::dispatch<asio::detail::rewrapped_handler<asio::detail::binder1<asio::detail::wrapped_handler<asio::io_context::strand, std::_Bind<void (restbed::detail::SocketImpl::*(restbed::detail::SocketImpl*, std::shared_ptr<restbed::detail::SocketImpl>, std::_Placeholder<1>))(std::shared_ptr<restbed::detail::SocketImpl>, std::error_code const&)>, asio::detail::is_continuation_if_running>, std::error_code>, std::_Bind<void (restbed::detail::SocketImpl::*(restbed::detail::SocketImpl*, std::shared_ptr<restbed::detail::SocketImpl>, std::_Placeholder<1>))(std::shared_ptr<restbed::detail::SocketImpl>, std::error_code const&)> > >(asio::detail::strand_service::strand_impl*&, asio::detail::rewrapped_handler<asio::detail::binder1<asio::detail::wrapped_handler<asio::io_context::strand, std::_Bind<void (restbed::detail::SocketImpl::*(restbed::detail::SocketImpl*, std::shared_ptr<restbed::detail::SocketImpl>, std::_Placeholder<1>))(std::shared_ptr<restbed::detail::SocketImpl>, std::error_code const&)>, asio::detail::is_continuation_if_running>, std::error_code>, std::_Bind<void (restbed::detail::SocketImpl::*(restbed::detail::SocketImpl*, std::shared_ptr<restbed::detail::SocketImpl>, std::_Placeholder<1>))(std::shared_ptr<restbed::detail::SocketImpl>, std::error_code const&)> >&) () from /usr/lib/librestbed.so.4
    #9  0x76d1fdfc in asio::detail::wait_handler<asio::detail::wrapped_handler<asio::io_context::strand, std::_Bind<void (restbed::detail::SocketImpl::*(restbed::detail::SocketImpl*, std::shared_ptr<restbed::detail::SocketImpl>, std::_Placeholder<1>))(std::shared_ptr<restbed::detail::SocketImpl>, std::error_code const&)>, asio::detail::is_continuation_if_running>, asio::any_io_executor>::do_complete(void*, asio::detail::scheduler_operation*, std::error_code const&, unsigned int) () from /usr/lib/librestbed.so.4
    #10 0x76ce492e in ?? () from /usr/lib/librestbed.so.4
    #11 0x76d31c78 in restbed::Service::start(std::shared_ptr<restbed::Settings const> const&) ()
       from /usr/lib/librestbed.so.4
    #12 0x54ac81b8 in https (config=..., ipcHandler=...)
        at /opt/yocto/sysroots/armv7at2hf-neon-poky-linux-gnueabi/usr/include/c++/9.3.0/ext/atomicity.h:96
    #13 0x54ab77d0 in std::__invoke_impl<void, void (*)(AppSrvConfig const&, std::shared_ptr<IpcHandlerInterface> const&), AppSrvConfig, std::shared_ptr<IpcHandlerInterface> > (__f=<optimized out>)
    
    opened by maggu2810 1
  • Fatal error: restbed: No such file or directory

    Fatal error: restbed: No such file or directory

    Hello guys, I am having some troubles with the library because i don't know so well how can i compile it using terminal, after the installation using CMAKE I tried to compile an example and the following message appears:

    fatal error: restbed: No such file or directory #include

    Is it necessary to put some header of restbed in my project? By the way the command that I am using is this: g++ -o example example.cpp -l restbed. If someone can help me I will be very pleasureful.

    opened by GuilhermeMonster 0
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 425 Jun 26, 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 77 Jun 9, 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 51 Dec 19, 2021
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 542 Jun 14, 2022
Enabling services on your device 66 Jun 23, 2022
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 839 Jun 27, 2022
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 6.9k Jun 22, 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 863 Jun 23, 2022
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.4k Jun 22, 2022
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 848 Jun 26, 2022
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.3k Jun 23, 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 8.4k Jun 24, 2022
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 126 Jun 24, 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 283 Jun 8, 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 2 May 23, 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 5 Apr 27, 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 46 Jun 15, 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
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 791 Jun 23, 2022