Routing with URI Templates - Austin Wright

Опубликовано: 17 Июль 2026
на канале: OpenAPI Initiative
282
9

URI Templates are a popular standard that allows clients to construct a URI according to the server's instructions, rather than following a hyperlink, or implementing manually-written directions in the documentation.

Wouldn't it be useful if you could use these same URI templates to handle incoming HTTP requests? I will show how to reverse this process, so that when a request is received, the URI can be routed to a matching URI Template, from among all of the ones used in the API; recovering the values used to fill in the variables.

I'll show applications for this technique, including a router that reads directly from an OpenAPI description, and detecting overlapping or ambiguous routes.

And I will show the basis in Automata Theory, starting by modeling URI Templates as a regular grammar, then taking the union of all of the URI Templates in use to produce a deterministic finite state machine to find the ones that match (in constant time, with respect to the size of the routing table!).

Finally, I'll discuss implications for various API description standards, including how to support nearly the full range of URI Template operators, and what it should mean when there's overlapping routes.