Skip to content

Examples and Tutorials

Lee Yunjin edited this page Oct 7, 2026 · 1 revision

Examples and Tutorials

Tutorial modules

tutorials/ holds 30 self-contained modules. Each has a runnable main.c, a CMakeLists.txt and a README; later modules assume the earlier ones.

cd tutorials/01-hello-world
mkdir build && cd build
cmake .. && make
./tut01
# Module Topic Wiki page
01 hello-world minimal server, GET routes Quick Start
02 routing-params /users/:id path parameters Routing
03 json-api JSON APIs with cJSON JSON
04 middleware-pipeline cwist_app_use Middleware
05 database-sqlite embedded SQLite Database
06 db-pool SQLite connection pool Database
07 jwt-auth signing JWTs, CWIST_DEFER_FREE JWT
08 sse-realtime Server-Sent Events Server-Sent Events
09 websocket-chat WebSocket handlers WebSocket
10 background-scheduler background jobs Scheduler
11 csrf-protection CSRF tokens CSRF and WAF
12 cookie-session cookies and sessions Sessions and Flash
13 compression-gzip-zstd gzip and zstd Compression
14 metrics-observability Prometheus /metrics Metrics and Health
15 multipart-upload file uploads Multipart Uploads
16 html-builder HTML element trees HTML Components
17 css-composer CSS generation HTML Components
18 healthz-check /healthz probes Metrics and Health
19 post-quantum-tls X25519MLKEM768 HTTPS and TLS
20 http3-quic-server HTTP/3 over QUIC HTTP/3 and QUIC
21 waf-security WAF-lite CSRF and WAF
22 rate-limiting rate limiter Middleware
23 cors-policy CORS Middleware
24 secure-headers CSP, X-Frame-Options Security
25 big-dumb-reply-cache BDR cache Big Dumb Reply Cache
26 generic-orm _Generic ORM helpers ORM
27 db-migrations schema migrations Database
28 transparent-column-encryption db_crypt Database
29 test-client-automation in-memory tests Testing
30 graceful-shutdown SIGTERM, cwist_full_gc(true) Graceful Shutdown

make tutorials-check compiles every tutorial against the current library; CI runs it in the sanitizer job.

Guides

Example applications

Runnable demos under example/:

Example Demonstrates
simple-server minimal HTTP server
http step-by-step HTTP features
db, db-crypt SQLite and encrypted database blobs
jwt issuing and verifying tokens
othello-web multiplayer WebSocket game over HTTPS
rps-showcase static caching and throughput
json-builder, html, template rendering helpers
micro, mem, siphash, sstring core utilities
cde-json-viewer JSON viewer app
webtransport WebTransport (experimental)
webrtc WebRTC DataChannel echo
wasm-service-worker CWIST compiled to WASM in a Service Worker
wasip2-kv WASI 0.2 key-value service
rust-hello Rust bindings
zig-hello Zig bindings

A production deployment built on CWIST: fly.board.

Clone this wiki locally