mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 22:30:41 +01:00
Dynamic http status code? #576
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @eetawil on GitHub (Feb 26, 2024).
Originally assigned to: @StefH on GitHub.
Hi,
I have this mock setup like this and now I want to also make the status code dynamic (200 or 400) based on the request that I will parse in the "GenerateBody" method, how can I achieve that here?
@StefH commented on GitHub (Mar 2, 2024):
So you are looking for this code?
which can be used like:
@eetawil commented on GitHub (Mar 4, 2024):
Yes this could work , but I was wondering if there's a way to do it in a single shot?
Here when generating the body dynamically can it also set the status code without the need of reprocessing the request again?
Or maybe the
Objreturned by GenerateBody =>Func<IRequestMessage, Obj>could be retrieved and reused in.WithStatusCode???@StefH commented on GitHub (Mar 4, 2024):
In that case. You need "WithCallback".
@eetawil commented on GitHub (Mar 5, 2024):
Thank you I didn't know about that, I'll look into that. Again, thank you for answering our questions and being available!