fabric8io / mockwebserver

An extension of okhttp's mockwebserver, that provides a DSL and is easier to use
Apache License 2.0
113 stars 38 forks source link

Could you provide examples for .post() and .withHeader() #58

Closed dmytro-verbivskyi closed 10 months ago

dmytro-verbivskyi commented 3 years ago

Hello. Thank you for your project.

Wanted to see examples how to provide expectations for payload during POST/PATCH/PUT request. Is there some plans to extend your library with it? Also .withHeader() method - as I can see it is only applicable for response part and not for request part of expectation.

Could you improve your documentation and answer me please?

manusa commented 10 months ago

We do support expectations for POST, PATCH, and PUT.

The Fabric8 Kubernetes Client has many tests which illustrate it.

We don't plan to support an expectation mode .withHeader. Meaning that the expectation routing won't support it directly. However, you can create an expectation (unique) for a given path and then customize the response using the .andReturn DSL method based on whatever conditions you want for the request header. This should be fine and enough for most use-cases.