This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Meander is a tiny async Python web framework (Python 3.12+) that automatically exposes Python functions as HTTP API endpoints. The core philosophy is separation of API wiring from code construction—functions are written normally without decorators, then wired to HTTP endpoints where parameters are automatically extracted from requests based on function annotations.
PYTHONPATH=. .venv/bin/pytest tests # Run all tests
.venv/bin/ruff check meander tests # Run ruff linter
.venv/bin/black meander tests # Format code with blackRun a single test:
PYTHONPATH=. .venv/bin/pytest tests/test_annotate.py -v
PYTHONPATH=. .venv/bin/pytest tests/test_annotate.py::test_function_name -vrunner.pymanages the async event loop and starts serversserver.pycreates Server instances that own a Routerconnection.pyhandles HTTP connections, parses requests, and dispatches to handlersrouter.pymatches URL patterns (regex) + HTTP methods to Route definitionsannotate.pyinspects handler function signatures, extracts parameters from requests, converts types, and invokes the handlerresponse.py/formatter.pyserialize results back to HTTP
- annotate.py: Core parameter extraction logic.
get_params()(cached) inspects function signatures;call()extracts values from requests, converts types, and invokes handlers - router.py:
Routerclass matches requests toRouteobjects. Routes use regex patterns.load()parses.routesconfig files - connection.py:
Connectionclass handles request lifecycle, logging (cid/rid tracking), error handling, and keep-alive - types_.py: Type converters (
boolean,integer,String) and special markers (ConnectionId,Ignore) - call.py: HTTP client for outbound requests with retry support
- parser.py / formatter.py: HTTP protocol parsing and serialization
Functions can use these annotations for automatic injection:
Request(aliased fromServerDocument): Inject the full HTTP request objectConnectionId: Inject connection/request ID stringIgnore: Skip parameter extraction for this argument