Skip to content
This repository has been archived by the owner on Oct 24, 2018. It is now read-only.
/ nx Public archive

C++11/14 asynchronous HTTP server and client library

License

Notifications You must be signed in to change notification settings

ExpandiumSAS/nx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

nx - Modern C++ HTTP library

nx is a simple and modern C++ library allowing fast development of HTTP servers and clients in just a few lines of code.

For example:

A simple "Hello World !" server:

#include <nx/nx.hpp>

using namespace nx;

int main(int ac, char **av)
{
    httpd srv;

    // Register a GET handler
    srv(GET) / "Hello" = [&](const request& req, buffer& data, reply& rep) {
        rep
            << text_plain
            << "Hello, world!"
            ;
    };

    // Bind and listen
    srv(make_endpoint("127.0.0.1", 3000));

    // Do something else while server asynchronously handles request...
}

The corresponding client:

#include <nx/nx.hpp>

using namespace nx;

int main(int ac, char **av)
{
    httpc cli;

    // Register a GET handler
    cli(
        GET,
        make_endpoint("127.0.0.1", 3000)
    ) / "Hello" = [&](const reply& rep, buffer& data) {
        if (rep) {
            std::cout
                << "server replied:\n"
                << data
                ;
        }
    };

    // Do something else...
}

About

C++11/14 asynchronous HTTP server and client library

Resources

License

Stars

Watchers

Forks

Packages

No packages published