How andyongh/api-server works
This is a C JSON-RPC API server. A client POST is parsed and authenticated by the HTTP handler, dispatched to a registered method, and returned synchronously or accepted as a background task. Task-management methods let users inspect and control those tasks. The README documents polling, cancellation, refresh, and listing; the sampled implementation confirms these stages. The task store is in-memory. Edges are limited to calls and startup wiring visible in excerpts or explicitly documented; unsampled integrations are omitted.
Main entry points: server.c HTTP server · methods.c Method registry · main.c Runtime startup · task_manager.c Task lifecycle
Components 13
Request handling
- HTTP server
src/server.c - JSON-RPC codec
src/jsonrpc.c - Authentication
src/auth.c
Methods and tasks
- Method registry
src/methods.c - Sync methods
src/methods.c - Async compute
src/methods.c - Task operations
src/methods.c - Task lifecycle
src/task_manager.c
Concurrency runtime
- Worker pool
src/worker_pool.c - Runtime startup
src/main.c
Shared support
- UUID generation
src/uuid.c - Thread-safe logging
src/log.h
Other components
- API client
Connections 15
- API client → HTTP server: sends requests
README.md - HTTP server → JSON-RPC codec: parses and formats
src/server.c - HTTP server → Authentication: verifies session
src/server.c - HTTP server → Method registry: looks up methods
src/server.c - HTTP server → Worker pool: submits work
src/server.c - HTTP server → Task lifecycle: creates tasks
src/server.c - Method registry → Sync methods: registers handlers
src/methods.c - Method registry → Async compute: registers handlers
src/methods.c - Method registry → Task operations: registers handlers
src/methods.c - Task operations → Task lifecycle: queries and updates
src/methods.c - Task lifecycle → UUID generation: generates task IDs
src/task_manager.c - Runtime startup → Task lifecycle: initializes and destroys
src/main.c - Runtime startup → Method registry: initializes
src/main.c - Runtime startup → Worker pool: creates and destroys
src/main.c - Runtime startup → HTTP server: starts and stops
src/main.c