Thomasdezeeuw / heph

Heph is an actor library for Rust based on asynchronous functions.
MIT License
129 stars 6 forks source link

HTTP router #493

Open Thomasdezeeuw opened 2 years ago

Thomasdezeeuw commented 2 years ago

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:

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

Blocked on #491.

Thomasdezeeuw commented 2 years ago

Pr https://github.com/Thomasdezeeuw/heph/pull/507 added the route! macro, but I'm leaving this open for a dynamic implementation.