Update context.go

Changed from iteration to lookup

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
Kristian Köhler 2025-06-27 09:42:04 +02:00 committed by GitHub
parent ac765410d3
commit adae8b76db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1316,12 +1316,10 @@ var negotiationRenderMappings = map[string]NegotiationRenderFunc{
func (c *Context) Negotiate(code int, config Negotiate) {
accepted := c.NegotiateFormat(config.Offered...)
for bind, fn := range negotiationRenderMappings {
if bind == accepted {
if fn, ok := negotiationRenderMappings[accepted]; ok {
fn(code, config, c)
return
}
}
c.AbortWithError(http.StatusNotAcceptable, errors.New("the accepted formats are not offered by the server")) //nolint: errcheck
}