Skip to content

Commit

Permalink
fix produces with type parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
martian4202 committed Jul 13, 2022
1 parent 5bcfe65 commit 1c6d707
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 1c6d707

Please sign in to comment.