Skip to main content

Module http_routing

Module http_routing 

Source
Expand description

Callee-text classification for server-side HTTP route/endpoint declarations.

Detects route-registration calls in Express/Koa/Fastify (TypeScript/JavaScript), Hono, Next.js route handlers, http.HandleFunc/Gin (Go), and add_url_rule (Python Flask/FastAPI imperative registration). Detection is anchored on the receiver token so that client-side HTTP calls (axios.get, fetch) stay in data_access.

§Receiver-allowlist precision

The TS/JS regex matches only when the call receiver is a known server/router handle: app, router, fastify, server, srv. Go adds http, mux, r, e, engine, g, rg. A client call like axios.get(url) (receiver axios) is outside every allowlist and correctly stays in data_access.

Documented limitation: An idiosyncratically-named server variable (const api = express(); api.get(...)) will not be detected — receiver-type inference would require a type-info pass outside the v0 node-kind model.

§NestJS / FastAPI distinction

NestJS route decorators (@Get('/'), @Post(...)) and FastAPI route decorators (@app.get(...), @app.post(...)) are decorator / decorated_definition nodes classified under decorators (M36.1/M36.2). They are intentionally not duplicated here — each route is counted once, under decorators.

§CALL_DISPATCH slot

Registered at P7 in CALL_DISPATCH — above logging (P8) and data_access (P9) so that app.get(...) / router.post(...) are peeled off before the broad data-access \b(get|post|...)\( regex matches them.

§Python add_url_rule

Flask/FastAPI also supports imperative app.add_url_rule('/path', view_func=h). This is not covered by decorators because it is a call, not a decorator. Matched by a member-call regex anchored on .add_url_rule(.

§Seeds forward

GraphQL resolvers, gRPC service methods, and tRPC routers are adjacent “endpoint declaration” idioms. Out of scope for M41; a future milestone could extend this category or introduce a sibling.

Constants§

NODE_KINDS
Tree-sitter node kinds for HTTP routing patterns.

Functions§

matches_callee
Return true when text looks like a server-side route/endpoint declaration.