Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support multi-segment and empty API prefixes #220

Merged
merged 1 commit into from
May 2, 2024
Merged

Commits on May 1, 2024

  1. 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.
    jbearer committed May 1, 2024
    Configuration menu
    Copy the full SHA
    9416c14 View commit details
    Browse the repository at this point in the history