Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Principle:8beeeaaat Touchdesigner mcp Schema Driven Request Routing

From Leeroopedia
Knowledge Sources
Domains Request_Routing, OpenAPI
Last Updated 2026-10-28 00:00 GMT

Overview

A routing strategy where the set of valid HTTP routes, their path patterns, and their handler bindings are derived from an OpenAPI schema's `operationId` rather than hand-coded route tables.

Description

In a schema-driven router, the OpenAPI specification is the single source of truth for the route table. At initialization, the router extracts RouteDefinition objects (method, path pattern, operationId, parameters) from the schema's `paths` section. Handlers are registered against `operationId` strings — not raw paths — so the binding is decoupled from the URL shape. Incoming requests are matched in two passes: first an exact string match on (method, path), then a parameterized pattern match that splits on `/` and captures `{param}` segments. A greedy last-segment rule lets trailing slashes in path parameters (common for TouchDesigner node paths like `/project1/geo1/circle1`) be captured intact. This approach eliminates route-table drift: changing the OpenAPI spec and regenerating automatically updates both the routes and the handler stubs.

Usage

Use this principle when a Python web framework runs inside a constrained runtime (like a TouchDesigner WebServer DAT) and the API surface is already defined in OpenAPI, so the router and handlers stay in sync with zero hand-written routing code.

Theoretical Basis

# Abstract algorithm (NOT real implementation)
routes = [Route(method, path, operationId) for path, ops in schema["paths"] for method, ops in ops]

def route_request(method, path, query, body):
    match = match_route(method, path, routes)  # exact, then parametric
    if not match:
        return error(NOT_FOUND)
    handler = handlers[match.route.operationId]
    params = {**match.path_params, **query}
    if method in (POST, PUT, PATCH) and body:
        params["body"] = body
    return handler(**params)

Key properties:

  • operationId as dispatch key: handler registration is path-agnostic.
  • Two-pass matching: exact match first (fast path), then parameterized (slow path).
  • Greedy last segment: `{nodePath}` captures `/`-delimited trailing segments.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment