HTTP/2 server library for C

Build HTTP servers in C

A compact Linux library with routing, middleware, JSON helpers, uploads, TLS, compression, metrics and graceful shutdown.

Open source · BSD 3-Clause · Linux

#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;
    cHTTPX_AppInit(&app);

    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);
    return cHTTPX_AppRun(&app);
}

High performance

Small C runtime with direct control over server behavior.

Easy to use

Routing, responses and helpers without repetitive HTTP plumbing.

Flexible

Middleware, TLS, gzip, metrics, JSON, uploads and custom limits.

Documented

Module-by-module documentation and runnable examples.

Open source

Read the code, contribute, fork it and build on top of it.

— GitHub stars
— Forks
— Open issues
— Latest release

Keep HTTP code small

Handlers contain application logic instead of repetitive request parsing, response building and server boilerplate.