mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-14 04:08:15 +08:00
Update context.go
Changed from iteration to lookup Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
parent
ac765410d3
commit
adae8b76db
@ -1316,11 +1316,9 @@ 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 {
|
||||
fn(code, config, c)
|
||||
return
|
||||
}
|
||||
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
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user