How to implement conditional request with custom condition that checks order status?
Example:
- User would sent GET /api/order with header "x-if-ready-for-payment": true.
- If order is ready for payment, response will be order and status code 200.
- If order is not ready for payment, response will be error message with status code 412.
Is that the right way or did I completely miss the point of the conditional requirements?
Conditional request are basically (but read more here) meant to:
If-None-Match,If-Modified-Since)If-Match,If-Unmodified-Since)See also RFC 7232, Hypertext Transfer Protocol (HTTP/1.1): Conditional Requests:
It's not meant for your custom business logic. Your
x-if-ready-for-paymentsounds like you're going to need to invent dozens of new headers that only apply to a single or handful of requests.Determine what problem you're actually trying to solve, and find a different solution.