-
Couldn't load subscription status.
- Fork 700
Open
Description
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:
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?
brackendawson
Metadata
Metadata
Assignees
Labels
No labels