We want to use ATS to protect a JSON API and image origin, we want all error messages to be returned as JSON to the client. It doesn't seem possible to configure ATS to return anything other than very simple HTML responses.
In Header Rewrite rules (HRW4U syntax):
- Inside
REMAP {…}, using http.status = 400 automatically changes the Content-Type to text/html
- Inside
REMAP {…}, inbound.resp.body can't be set to anything other than basic text. It also doesn't seem possible to place quotes or newlines in this string?
- Inside
REMAP {…}, inbound.resp.Content-Type isn't supported. Why am I allowed to set the body to a string, but not this header?
set-body-from is only supported inside READ_RESPONSE {…}, where it replaces a potentially cached item
In the body factory system:
I cannot find any way to get body_factory to produce JSON documents in places where ATS responds with its own errors, it's always text/html
Am I completely missing something? Is there a way to send JSON when you want to return a 4XX or 5XX error?
We want to use ATS to protect a JSON API and image origin, we want all error messages to be returned as JSON to the client. It doesn't seem possible to configure ATS to return anything other than very simple HTML responses.
In Header Rewrite rules (HRW4U syntax):
REMAP {…}, usinghttp.status = 400automatically changes theContent-Typetotext/htmlREMAP {…},inbound.resp.bodycan't be set to anything other than basic text. It also doesn't seem possible to place quotes or newlines in this string?REMAP {…},inbound.resp.Content-Typeisn't supported. Why am I allowed to set the body to a string, but not this header?set-body-fromis only supported insideREAD_RESPONSE {…}, where it replaces a potentially cached itemIn the body factory system:
I cannot find any way to get
body_factoryto produce JSON documents in places where ATS responds with its own errors, it's alwaystext/htmlAm I completely missing something? Is there a way to send JSON when you want to return a 4XX or 5XX error?