LukeMathWalker / LukeMathWalker/wiremock-rs
async `respond_with` / `Respond`
- Dominant language
- Rust
- Stars
- 799
- Forks
- 91
- PR merge metrics
- No merged PRs in 30d
Description
Thanks for wiremock! It seems that it's currently not possible to execute async code in the respond method or respond trait. It'd be useful to have it natively supported by wiremock.
Wasn't able to find a workaround, tried
```rust
.respond_with(move |req: &Request| {
let handle = tokio::runtime::Handle::current();
std::thread::spawn(move || {
handle.block_on(async {
// Some async call
});
})
.join()
.unwrap();
ResponseTemplate::new(200)
})
```
but that's blocking the tokio runtime since the test runs as `#[tokio::test]`.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading the respond_with API and the Respond trait mentioned in the issue, then trace how the response callback is executed under a Tokio test runtime. Define the supported async callback behavior and verify that an async response can run without blocking the runtime.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100