![]() |
The example/
directory contains complete, buildable programs, one per common use case. The
CMake target name matches the file name minus the extension (cmake --build build
--target
rest_crud_server), and cmake --build build
--target
examples builds them all. Each file
starts with the curl commands
that exercise it.
Table 1.1. Examples shipped with the library
|
Example |
What it shows |
|---|---|
|
The smallest complete server: two REST routes, a path argument, a
query argument with a default, and graceful shutdown on |
|
|
A JSON REST API: CRUD routes over an in-memory store, typed request
bodies via |
|
|
A single-page application behind |
|
|
Per-connection state with |
|
|
Cookie-keyed sessions with |
|
|
Streaming in both directions: server-sent events from a timer, a
JSON stream from an |
|
|
The cancellation model end to end: an event stream that stops when
its client disconnects or the server shuts down, a JSON-RPC job that
checks its |
|
|
Asynchronous handlers: a coroutine that fetches an upstream URL with Beast and returns the response, plus a timer-based delay route. |
|
|
HTTPS with |
|
|
Protocol upgrade to WebSocket via |
|
|
A JSON-RPC 2.0 calculator: named parameters, batches, notifications,
a custom error mapper, and per-client state through |
|
|
An MCP server over Streamable HTTP: tools with generated input schemas,
resources and URI templates, a prompt, resource subscriptions, per-session
state, a tool returning typed content with an embedded resource,
a blob resource, a tool that notifies its own caller through |
|
|
One task board exposed over REST (cookie sessions, constrained arguments,
OpenAPI with a bearer scheme and components), JSON-RPC and MCP (annotated
tools, templated resources, prompt completion, elicitation, logging),
plus a per-user event stream under |
|
|
The same MCP tools served over stdio, the transport desktop clients launch locally. |
Start with hello_server.cpp, then the example closest to what you
are building.