Documentation

Start small, add features when you need them

A short guide to installation, the first server and the full libchttpx module documentation.

Installation

For Debian and Ubuntu on amd64, add the libchttpx APT repository once and install the development package normally.

Debian / Ubuntu
curl -fsSL https://netcorelink.github.io/libchttpx/apt/libchttpx.sources \
  | sudo tee /etc/apt/sources.list.d/libchttpx.sources >/dev/null

sudo apt update
sudo apt install libchttpx-dev

After that, future versions are installed through the normal APT update flow:

Update
sudo apt update
sudo apt upgrade

To remove libchttpx:

Remove
sudo apt remove libchttpx-dev

The APT repository currently targets Debian/Ubuntu on amd64 and uses Trusted: yes, so there is no separate GPG-key setup. Package signing can be added later.

Build from source

If you do not want to use the APT repository, the existing source installation remains available.

Source build
sudo apt update
sudo apt install -y build-essential pkg-config libcjson-dev zlib1g-dev

git clone https://github.com/netcorelink/libchttpx.git
cd libchttpx

make lin-lib
sudo make lib-install PREFIX=/usr/local DESTDIR=

Your first server

Create an app, configure a server, add a route, then run the app.

server.c
#include <libchttpx.h>

static void health(chttpx_request_t* req,
                   chttpx_response_t* res)
{
    (void)req;
    *res = cHTTPX_ResMessage(cHTTPX_StatusOK, "healthy");
}

int main(void)
{
    chttpx_app_t app;
    if (cHTTPX_AppInit(&app) != CHTTPX_OK)
        return 1;

    chttpx_config_t config = cHTTPX_DefaultConfig();
    config.port = 8080;

    chttpx_serv_t* server =
        cHTTPX_AppServer(&app, "main", &config);

    chttpx_router_t router =
        cHTTPX_RoutePathPrefix(server, "");

    cHTTPX_Get(&router, "/health", health);

    int result = cHTTPX_AppRun(&app);
    cHTTPX_AppShutdown(&app);
    return result == CHTTPX_OK ? 0 : 1;
}

Modules

Filter the list and open the full module documentation directly on this site.

Compile your application

After installation, use pkg-config to get include and linker flags.

Terminal
gcc server.c -o server $(pkg-config --cflags --libs libchttpx)
./server

Full documentation

All module documentation is available on this website. Start with the App runtime and move through the modules as needed.