Skip to content

Commit

Permalink
Merge pull request #251 from xmac1/fix-produces-with-type-parameters
Browse files Browse the repository at this point in the history
fix produces with type parameter
  • Loading branch information
casualjim committed Jul 14, 2022
2 parents 5bcfe65 + 1c6d707 commit 53ffffd
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion middleware/context.go
Expand Up @@ -498,7 +498,9 @@ func (c *Context) Respond(rw http.ResponseWriter, r *http.Request, produces []st

if resp, ok := data.(Responder); ok {
producers := route.Producers
prod, ok := producers[format]
// producers contains keys with normalized format, if a format has MIME type parameter such as `text/plain; charset=utf-8`
// then you must provide `text/plain` to get the correct producer. HOWEVER, format here is not normalized.
prod, ok := producers[normalizeOffer(format)]
if !ok {
prods := c.api.ProducersFor(normalizeOffers([]string{c.api.DefaultProduces()}))
pr, ok := prods[c.api.DefaultProduces()]
Expand Down

0 comments on commit 53ffffd

Please sign in to comment.