mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-14 12:12:12 +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) {
|
func (c *Context) Negotiate(code int, config Negotiate) {
|
||||||
|
|
||||||
accepted := c.NegotiateFormat(config.Offered...)
|
accepted := c.NegotiateFormat(config.Offered...)
|
||||||
for bind, fn := range negotiationRenderMappings {
|
if fn, ok := negotiationRenderMappings[accepted]; ok {
|
||||||
if bind == accepted {
|
fn(code, config, c)
|
||||||
fn(code, config, c)
|
return
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
c.AbortWithError(http.StatusNotAcceptable, errors.New("the accepted formats are not offered by the server")) //nolint: errcheck
|
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