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
Is it possible to use WireMock as a middleware? #1035
Comments
@adrianiftode I guess you are using a modern .NET version like 6 or higher? There is already an internal class named
Maybe that can be used? |
Yes, but the reason for asking this is I would like to deploy it with the tested service. I have a service ServiceB that I would like to mock. I want to configure WireMock inside ServiceA. So when ServiceA is started, the Mocked ServiceB is also started and ready to accept requests. The Mock should listen to any HTTP request to a path that starts with I will give it a try to the WireMockMiddleware. To expand this, I would also like to deploy a WireMock image configured with different mocked services
This image is then deployed and accessible from the Sandbox/Tests servers, and it has some kind of "mock isolation". So each path prefix has its own WireMock configuration. |
A quick question: Why not deploy 1 (or multiple) docker container(s) of WireMock.Net ? |
Even deploying it within a separated container, I was hoping to be a single one. I think I will go with this route anyway (multiple containers, one per every mocked service) |
Or use one container and register the mappings with a prefix in the path? |
Why not just use wiremock as a docker container using docker compose, see https://github.com/matteus6007/MyDomain.Api.Template/blob/main/docker-compose.dev-env.yml#L58 as an example of setting this up, then add your mocks in the normal JSON format into the |
I actually built this as a combination of a .NET HostedService (for Wiremock Server) and a DelegatingHandler which checks the original request headers for something like "X-WireMockStatus" and then rerouted all HttpClient calls to WireMockServer. This worked well to allow me to run this WireMockServer in all our lower environments for testing purposes. |
Currently I see that I can use wiremock hosted in different forms, however what I would like to do is to have a path prefix and everything after that path to be handled by wiremock.
So something like
I would like to deploy an arbitrary .NET Service, but still use wiremock at the port 80 and let it handle some prefixed requests.
The text was updated successfully, but these errors were encountered: