SttpClientInterpreter and constant headers


We have endpoints defined with some constant headers, eg:

.out(header(Header.cacheControl(Public, MaxAge(1 hour), StaleWhileRevalidate(1 day))))

The endpoints definitions are shared between server and clients. The problem is when interpreting these endpoints on client side, we get a client that throws a Mismatch error whenever we don’t get “this exact header = this exact value”. (it happens in this case because we have a gateway in the middle that modifies cache headers)

Any elegant way to manage this ? Some workarounds I can imagine:

  • Consider those are implementation dependent and move them out of the API definition
  • Make the header dynamic instead of constant
  • Make the header optional

I’d go with the first solution. You can have multiple levels of endpoint definitions. The base level, used for API documentation and generated clients, and then extended level that adds .out(header(...)). These endpoint definitions are then used when defining the server. HTTP cache seems like an auxiliary concern which, like in your case, can be handled (or updated) by gateways. I don’t think it should necessary be specified in API docs.