-
Notifications
You must be signed in to change notification settings - Fork 73
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
async respond_with
/ Respond
#84
Comments
What kind of async tasks are you trying to perform in |
It's some business logic, in this case it's |
I'll need an example a bit more concrete to understand if it makes sense to extend the library or not 😄 |
Personally I'd say it'd make sense to have callbacks be async in general unless there's a good reason to not do it. Reason being that it's easy to have a sync wrapper in an async context but it's hard the other way around. In this specific case I'm testing the correct setup of a FHIR Subscription. The HTTP request flow looks like this. The relevant part is 9. and 10. where a handshake takes place. Basically:
The library exposing the functionality has an async method |
Hey there, thanks for this great library! I recently ran into the same issue. Trying to call some async code from a custom responder. Basically, I am trying to create a mock to validate an HTTP payload and one of the libraries to parse multipart data is async. e.g. struct CustomResponder;
impl wiremock::Respond for CustomResponder {
fn respond(&self, req: &wiremock::Request) -> wiremock::ResponseTemplate {
// ... some logic ...
// This is an async function so can't be used here
let multipart = multer::Multipart::with_reader(req.body.as_slice(), boundary);
// ... validate multipart data ...
} A lot of http libraries have gone async so it would be useful to be able to use them |
Just another example in case it helps: |
The multipart crate has been unmaintained for a while, replace with multer which e.g. also used by axum. Unfortunately multer is async only, while the wiremock Response trait is sync[0]. So that does require some hoops to jump through for now. 0: LukeMathWalker/wiremock-rs#84 Signed-off-by: Sjoerd Simons <[email protected]>
The multipart crate has been unmaintained for a while, replace with multer which e.g. also used by axum. Unfortunately multer is async only, while the wiremock Response trait is sync[0]. So that does require some hoops to jump through for now. 0: LukeMathWalker/wiremock-rs#84 Signed-off-by: Sjoerd Simons <[email protected]>
The multipart crate has been unmaintained for a while, replace with multer which e.g. also used by axum. Unfortunately multer is async only, while the wiremock Response trait is sync[0]. So that does require some hoops to jump through for now. 0: LukeMathWalker/wiremock-rs#84 Signed-off-by: Sjoerd Simons <[email protected]>
The multipart crate has been unmaintained for a while, replace with multer which e.g. also used by axum. Unfortunately multer is async only, while the wiremock Response trait is sync[0]. So that does require some hoops to jump through for now. 0: LukeMathWalker/wiremock-rs#84 Signed-off-by: Sjoerd Simons <[email protected]>
Wanted to share my 2c and use case, that I posted on the wrong repo initially lol. First of all, thanks for this project, it's quite useful for us over at the Matrix Rust SDK project. There's one thing that I miss and would like to see: the ability to set This would allow for new functionality that I'd also like to be able to use, and that as far as I can't tell doesn't exist (but that would be great to prove me wrong :))
|
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
but that's blocking the tokio runtime since the test runs as
#[tokio::test]
.The text was updated successfully, but these errors were encountered: