-
-
Notifications
You must be signed in to change notification settings - Fork 214
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
Add Header Response by using interceptor #497
Comments
@duychuongvn
|
Hi @StefH , Thank you very much for your help. |
Please let me know if this works for you, so I can close this issue. |
Hi @StefH , It works. This is my solution: var responseMappings = Server.Mappings.Where(x => x.Provider is Response);
foreach (var mapping in responseMappings)
{
Response responseProvider = (Response)mapping.Provider;
var responseMessage = responseProvider.ResponseMessage;
responseProvider.WithCallback(requestMessage =>
{
var response = new ResponseMessage()
{
StatusCode = responseProvider.ResponseMessage.StatusCode,
};
response.BodyData = GetBodyData(responseMessage);
var signature= SignMessage(requestMessage, response.BodyData.BodyAsString);
response.AddHeader(CONTENT_TYPE, TEXT_XML);
response.AddHeader(XRESPONSE_HEADER, signature);
return response;
});
} Cheers, |
In your case : I would not loop the mappings and update the response, but just register that server
.Given(Request.Create().WithPath("/test").UsingGet())
.RespondWith(Response.Create().WithCallback(requestMessage =>
{
string body = "My Body data";
var response = new ResponseMessage()
{
StatusCode = 200,
BodyData = body
};
var signature = SignMessage(requestMessage, body);
response.AddHeader(CONTENT_TYPE, TEXT_XML);
response.AddHeader(XRESPONSE_HEADER, signature);
return response;
})); Or is this not possible in your scenario? |
Hi @StefH |
Ah I see. |
Hello,
I'm deploying API based on .NetCore 3.0, I would like to use WireMock on .NetCore too.
I have an issue:
Some 3rd API require Signature to verify client request and ask client to verify their responses.
It means that to integrate with 3rd party, we have to add Siguature to Request Header and verify Signature in the Response Header from 3rd party too.
We are using admin mock interface (read all mock data in the folder).
How can we apply the interceptor to genrate Signature based on each mock data?
Note: In the signature, there is dynamic information like timestamp, we cannot fix this value in the mock data
Thank you for you support.
The text was updated successfully, but these errors were encountered: