As with #41, I'm trying to have Gin negotiate a custom mediatype. From the client, I'm sending the following request header:
Accept: application/problem+json, application/json
And on the server, I'm trying to negotiate all errors (with middleware) as such:
problem := Problem{
Detail: errorText,
Status: status,
Title: http.StatusText(status),
}
c.Negotiate(status, gin.Negotiate{
Offered: []string{"application/problem+json", gin.MIMEJSON, gin.MIMEHTML},
HTMLName: "error",
HTMLData: &problem,
JSONData: &problem,
})
However, somewhere before I'm able to handle the error, Gin intercepts and for some reason decides that the requested Accept header can't be satisfied, writes the following to the log, and responds with 406 Not Acceptable:
Error #01: the accepted formats are not offered by the server
I would love to see a full example of how content negotiation a custom mediatype in Gin works. Would you be able to contribute your working code @jarrodhroberson?
As with #41, I'm trying to have Gin negotiate a custom mediatype. From the client, I'm sending the following request header:
Accept: application/problem+json, application/jsonAnd on the server, I'm trying to negotiate all errors (with middleware) as such:
However, somewhere before I'm able to handle the error, Gin intercepts and for some reason decides that the requested
Acceptheader can't be satisfied, writes the following to the log, and responds with406 Not Acceptable:I would love to see a full example of how content negotiation a custom mediatype in Gin works. Would you be able to contribute your working code @jarrodhroberson?