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

Add (optional) router to oxhttp #4

Open
chrisglass opened this issue Aug 18, 2022 · 1 comment
Open

Add (optional) router to oxhttp #4

chrisglass opened this issue Aug 18, 2022 · 1 comment

Comments

@chrisglass
Copy link

chrisglass commented Aug 18, 2022

The only thing preventing me from using this otherwise superb http server in more projects, is having some kind of router easily available/reusable.

Ideally, something that would also be capable of extracting URL parameters would be great.

If this is a desired feature, I'm happy to spend some time to implement it.

@Tpt
Copy link
Contributor

Tpt commented Aug 18, 2022

The only thing preventing me from using this otherwise superb http server in more projects

Thank you for the very kind word. It's amazing to see other users of oxhttp. I built it because I wanted to have an HTTP library allowing to stream request and response bodies without having to rely a lot on an async I/O library.

is having some kind of router easily available/reusable.
If this is a desired feature, I'm happy to spend some time to implement it.

That's a great question. I am more keen to keep this library as lightweight as possible. Inside of Oxigraph I just use a match statement and it served me well to implement a REST API.
If you want to add stuff like argument extraction from the path based on URL patterns... maybe building an other crate would make sense (this crate might not even have to depend directly on oxhttp). This way you would be able to iterate without having to wait for code reviews and oxhttp users who don't care about it would not have to pull it in.

Ideally, something that would also be capable of extracting URL parameters would be great.

For query paramters, this is already built-in thanks to the Url crate. request.url().query_pairs() should do the job. For path, this is an other topic (c.f. supra).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants