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

HTTP router #493

Open
Thomasdezeeuw opened this issue Sep 19, 2021 · 1 comment
Open

HTTP router #493

Thomasdezeeuw opened this issue Sep 19, 2021 · 1 comment
Labels
HTTP Related to the Heph-HTTP crate. idea An idea, open to discussion.

Comments

@Thomasdezeeuw
Copy link
Owner

To route HTTP request based on the method and URL to the correct Service (#491).

impl Route {
    fn route<S>(&mut self, method: Method, url: &str, service: S) {
        // ...
    }

    fn get<S>(&mut self, url: &str, service: S) {
        self.route(Method::Get, url, service)
    }
}

Two additional useful features:

  • Wildcards, e.g. /static_files/* would route any URL that starts with /static_files/ to a service.
  • URL parameters, e.g. /user/{handle} would extract handle from the URL.

Possible data structure: https://en.wikipedia.org/wiki/Trie.

Blocked on #491.

@Thomasdezeeuw Thomasdezeeuw added idea An idea, open to discussion. HTTP Related to the Heph-HTTP crate. labels Sep 19, 2021
@Thomasdezeeuw Thomasdezeeuw mentioned this issue Sep 19, 2021
57 tasks
@Thomasdezeeuw
Copy link
Owner Author

Pr #507 added the route! macro, but I'm leaving this open for a dynamic implementation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
HTTP Related to the Heph-HTTP crate. idea An idea, open to discussion.
Projects
None yet
Development

No branches or pull requests

1 participant