Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support multi-segment and empty API prefixes
It is sometimes useful to have an API where different modules internally look like parts of the same module to clients. For example, in the sequencer we have `state/fee/:height/:account` and `state/blocks/:height/index`, which look like two different endpoints in `state` module, but are actually two separate modules, `state/fee` and `state/blocks`. For this, we need multi-segment API prefixes. Separately, it is often desirable when a service has only one module to host that module at the root URL, instead of adding some dummy prefix like `/api`. For this, we need empty API prefixes. This change generalizes API dispatching to sequences of path segments rather than singular path segments, using a trie data structure to match (prefixes of) URL paths with API modules. We enforce that only the leaves of this trie contain actual data; in other words, it is disallowed, for clarity's sake, to have an API module whose path is a prefix of a different module.
- Loading branch information