Skip to content

async respond_with / Respond #84

Open
@johannescpk

Description

@johannescpk

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

.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].

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions