Home

Awesome

Restbed 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

FeatureDescription
WebSocketsFull-duplex communication channels over a single TCP connection.
Server-Sent EventsServer-Sent Events enables efficient server-to-client streaming of text-based event data—e.g., real-time notifications or updates generated on the server.
CometLong polling model to allow long-held HTTP requests for pushing data from the server to client.
SSL/TLSSecure over the wire communication allowing you to transmit private data online.
Session ManagementCreate custom HTTP session persistence and management logic.
HTTP PipeliningA technique allowing multiple HTTP requests to be sent on a single TCP connection without waiting for the corresponding responses.
Path ParametersAnnotate URIs with custom path parameters such as resource keys, revisions, etc...
Query ParametersAutomated query parameter parsing.
Header FiltersFilter incoming HTTP requests by headers.
LoggingCustomise how and where log entries are created.
Multi-Path ResourcesGive a resource multiple paths for improved readability.
Customisable MethodsAdd your own custom HTTP methods.
CompressionAdaptability to address any form of compression GZip, Deflate, etc...
EncodingAdaptability to address any form of encoding UTF-32, ASCII, etc...
Rules EngineReduce complexity by processing incoming requests with readable units of code.
HTTP/HTTPSBuilt in client capabilities with optional SSL peer certificate verification. Deprecated
IPv4/IPv6Internet Protocol Version 4/6 Network Support.
ArchitectureAsynchronous single or multi-threaded architecture, capable of addressing the C10K problem.
ConvertersBuilt-in Path, Query, and Header conversions for primary data-types.
AuthenticationSeparate Service and/or Resource level authentication.
Error HandlingSeparate Service and/or Resource level error handling.
Address BindingBind HTTP and/or HTTPS services to separate IP addresses.
Signal HandlingCapture OS generated process signals.
DocumentationHigh-quality documentation covering the architecture and API.
ComplianceFlexibility to address HTTP 1.0/1.1+ compliance.
MatureSecure, Stable, and extensively tested since 2013.
CommunityActive, vibrant and energetic open source community.
SupportCommercial 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 sales@corvusoft.co.uk, 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.

Build Options

OptionDescriptionDefault
BUILD_SSLEnable SSL/TLS support.Enabled
BUILD_IPCEnable Unix domain sockets.Disabled
BUILD_TESTSBuild project test suites.Enabled
BUILD_DEVEL_PACKAGEInstall headers into CMAKE_INSTALL_PREFIX.Enabled
BUILD_SHARED_LIBRARYProduce a shared build of restbed.Enabled
BUILD_STATIC_LIBRARYProduce a static build of restbed.Enabled

Windows Build Instructions

Prerequisites: Visual Studio 2022, CMake, GIT, Perl.

Using the x64 Native Tools Command Prompt begin by, if required, building OpenSSL.

git clone --recursive https://github.com/corvusoft/restbed.git

cd restbed\dependency\openssl
perl Configure [no-]shared
nmake
nmake test

If you selected to use the default OpenSSL build (shared), you'll need to include the installation path in your environment.

set PATH=restbed\dependency\openssl;%PATH%

If you selected to use the static OpenSSL build (no-shared), you'll need to include additional dependencies when linking your application code; See OpenSSL project for futher details.

target_link_libraries( my_microservice restbed-static.lib ws2_32.lib advapi32.lib crypt32.lib gdi32.lib user32.lib )

Now proceed with the following Restbed build instructions.

mkdir restbed\build
cd restbed\build
cmake -G "Visual Studio 17 2022" [-DBUILD_SSL=NO] [-DBUILD_TESTS=NO] ..
cmake --build . --target ALL_BUILD --config Release
ctest

For Microsoft Visual Studio 14 2015 instructions, and further details, 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

ResourceRequirement
CompilerC++14 compliant or above
OSBSD, Linux, Mac OSX, Windows, Raspbian

Road Map

MilestoneFeatureStatus
0.0Asynchronous HTTP Servicecomplete
1.0HTTP 1.0 Compliancecomplete
2.0HTTP 1.1 Compliancecomplete
2.5Secure Socket Layercomplete
2.5Simultaneous Network Ports (HTTP/HTTPS)complete
3.0Rules Enginecomplete
3.5Schedule Tasks on Service run-loopcomplete
3.5Multi-Threaded service capabilitycomplete
3.5Bind Service to specific Addresscomplete
3.5Session Managementcomplete
4.0HTTP Clientcomplete
4.0Signal Handlingcomplete
4.5API Documentationcomplete
4.5Web Socketscomplete
5.0Client-side SSL certificatesdevelopment
5.0Resource Cachingdevelopment
5.0Runtime Modificationsdevelopment
5.0HTTP 2 compliancedevelopment
5.0Refactor, Reduce, Reuseactive

Contact

MethodDescription
TwitterTweet us your questions & feature requests.
support@corvusoft.co.ukSupport related queries.
sales@corvusoft.co.ukSale related queries.