http-rs / http-rs/surf

Allow applying middleware before know about request uri and methods

Open
#126 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Rust
Stars
1.5k
Forks
128
PR merge metrics
No merged PRs in 30d

Description

Currently the `middleware` function is under `Request`.

I am trying to create and reuse a client, a sign will be calculated base on the url path and query.
Is it possible that I can create a http client with applied middleware before know about any uri and http methods?

Basically it's request/response interceptor.

for example:
```rust
let client = surf::Client::new();
let client = client.middleware(...) // no middleware func exist in the client

let request = Request { client }

// the middleware func will be executed before sending out the request
request.client.get("https://httpbin.org/get").recv_string();
```

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.