Consideration for returning `Request` type which is a bit complex right now
- Dominant language
- Rust
- Stars
- 1.5k
- Forks
- 128
- PR merge metrics
- No merged PRs in 30d
Description
## Description
Returning `Request` type is a bit complex right now.
It takes a bit of work to figure out what to do to achieve this.
## Why
Being able to return the `Request` is a common need.
Consider the example of a simple Proxy -
```
use surf::{Request as RequestAsClient, Response as ResponseAsClient};
use tide::{Request as RequestAsServer, Response as ResponseAsServer};
/// Receives request from client, returns corresponding request object
/// to the downstream server
pub fn map_request(
request_from_client: RequestAsServer<()>,
) -> RequestAsClient {
unimplemented!()
}
```
## Issues
Does not work with any version other than Surf `2.0.0-alpha` as
1. `surf::http_client` is not re-exported
2. `http_client::HttpClient` complains its a different type and the `impl` does not exist.
Rightly so because it has a different version of `http-client`.
This works (compiles) only if `RequestAsClient` is provided by using Surf `2.0.0-alpha`.
Even with `2.0.0-alpha`, my assumption was to use `RequestAsClient` but that throws error
```
|
8 | ) -> RequestAsClient {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expands to a recursive type
|
= note: type resolves to itself
```
## Consideration
I am not sure what needs to be done but could returning Request be made a bit easier?
I am told that there is `http-types` in the works. Is that going to help eventually
align these?
cc @jbr
Contributor guide
Assessment
This issue has not been assessed yet.