简体   繁体   中英

Wiremock capture response body for later reuse

I'm facing a particular use case while using Wiremock standalone API.

I would like to be able to reuse a response body generated by stubbing for a another request (stubbed as well) as a context model. The purpose is to store for a generated Id the entire response data, that would allow me to serve it again simply knowing the Id, in a get method particularly (where there is no request body). Is there a way while defining a stub of response to capture the generated response, in order to store it?

Or if you have other better idea.

Finally I solved the problem by using an okhttp interceptor (which depends on your client solution).

In the interceptor, I store every response data (eg: a generated ID) and set them in every next request headers when it matches with part of the the response stored.

adding them to the request headers allows me to access them in a json template file for instance

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM