http-rs / http-rs/tide

Consider moving `State` off of `Request`

Open
#643 11 comments 1 reaction 0 assignees View on GitHub
Dominant language
Rust
Stars
5.1k
Forks
329
PR merge metrics
No merged PRs in 30d

Description

It would be nice to not have `Request` have a generic parameter, for e.g. the `AsyncRead` trait which requires pinning. See https://github.com/http-rs/tide/pull/642#issuecomment-657141853 for where this was originally encountered.

However in interest of keeping middleware simple it would still be nice to allow `(Request, Next) -> Fut>`, but for `State` it would probably ideal to have an extra parameter, kinda like Surf's `Client`, e.g. `(Request, State, Next) -> Fut>`.

I was thinking maybe `server.middleware()` / endpoints could take `impl Into>` / endpoint, and so then that trait could be applied to both of the above with an extra function wrapper for the simple case, allowing both to work, and scoping `State` to the middleware/endpoint stack.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.