ContentType provides a filter to adjust response content types. This is used to ensure e.g. `application/problem+json` content types defined in RFC 9457 Problem Details for HTTP APIs are used in responses to clients.
(ct string)
| 125 | // used to ensure e.g. `application/problem+json` content types defined in |
| 126 | // RFC 9457 Problem Details for HTTP APIs are used in responses to clients. |
| 127 | func (e *ErrorModel) ContentType(ct string) string { |
| 128 | if ct == "application/json" { |
| 129 | return "application/problem+json" |
| 130 | } |
| 131 | if ct == "application/cbor" { |
| 132 | return "application/problem+cbor" |
| 133 | } |
| 134 | return ct |
| 135 | } |
| 136 | |
| 137 | // ContentTypeFilter allows you to override the content type for responses, |
| 138 | // allowing you to return a different content type like |