CWEB API reference (public library)
This documentation describes the public symbols from the headers under framework/include/cweb/, which you include in an application project (#include <cweb/…> after installing libcweb-dev).
Conventions
- Memory: Unless stated otherwise, dynamically allocated memory is owned by the caller (
freeor framework helpers likecweb_free_*). - Threads: Assume one event-loop thread per process unless explicitly marked “thread-safe” (especially logger).
- Naming: Canonical prefixes are
cweb_*,cwagger_*,fetch_*,session_*(session store).fileserver.halso has additional legacy inline aliases without prefix; prefer thecweb_*variants.
Module overview
| Module | File | Contents |
|---|---|---|
| Main entry | cweb.md | Central includes, frontend asset registration |
| HTTP | http.md | Request, Response, headers, serialization |
| Routing | routing.md | Register routes, fallback, dynamic paths |
| Server / event loop | server.md | Start server, pending responses, libevent |
| File server / cache | fileserver.md | Static assets, cache, MIME |
| Compression | compress.md | Brotli, Gzip, Accept-Encoding, minify |
| Templates / output | template.md | HTML output buffer, asset links |
| Template codegen (CLI) | codegen.md | Lexer/parser/AST for .cweb templates (build time) |
| HTTP client (async) | fetch.md | libcurl + libevent, JSON helpers |
| Cwagger | cwagger.md | API docs (OpenAPI-light) |
| Sessions | session.md | In-memory session store |
| Development / ops | dev.md | Prod vs. dev mode |
| Paths & query | pathutils.md | URL/path helpers |
| Async helpers | async.md | Callback on event loop |
| Autofree | autofree.md | GCC/Clang cleanup attributes |
| Logger | logger.md | Levels, LOG_* macros |
| Leak tracker | leak-detector.md | Debug allocation tracking |
| Speedbench | speedbench.md | Simple runtime measurements |
Further per-function details are in the linked module files.