Skip to content

Can't find a way to serve JSON errors #13393

Description

@csuhta

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?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions