NegotiateFormat() — gin Function Reference
Architecture documentation for the NegotiateFormat() function in context.go from the gin codebase.
Entity Profile
Dependency Diagram
graph TD eeea1018_1f11_4561_313c_6236f45a9d03["NegotiateFormat()"] 08757a7b_89f3_7a60_ac08_6c15ecf7b5bd["Negotiate()"] 08757a7b_89f3_7a60_ac08_6c15ecf7b5bd -->|calls| eeea1018_1f11_4561_313c_6236f45a9d03 8e2593fb_827b_15b4_e0ed_5b628a19e625["requestHeader()"] eeea1018_1f11_4561_313c_6236f45a9d03 -->|calls| 8e2593fb_827b_15b4_e0ed_5b628a19e625 style eeea1018_1f11_4561_313c_6236f45a9d03 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
context.go lines 1393–1421
func (c *Context) NegotiateFormat(offered ...string) string {
assert1(len(offered) > 0, "you must provide at least one offer")
if c.Accepted == nil {
c.Accepted = parseAccept(c.requestHeader("Accept"))
}
if len(c.Accepted) == 0 {
return offered[0]
}
for _, accepted := range c.Accepted {
for _, offer := range offered {
// According to RFC 2616 and RFC 2396, non-ASCII characters are not allowed in headers,
// therefore we can just iterate over the string without casting it into []rune
i := 0
for ; i < len(accepted) && i < len(offer); i++ {
if accepted[i] == '*' || offer[i] == '*' {
return offer
}
if accepted[i] != offer[i] {
break
}
}
if i == len(accepted) {
return offer
}
}
}
return ""
}
Domain
Subdomains
Calls
Called By
Source
Frequently Asked Questions
What does NegotiateFormat() do?
NegotiateFormat() is a function in the gin codebase.
What does NegotiateFormat() call?
NegotiateFormat() calls 1 function(s): requestHeader.
What calls NegotiateFormat()?
NegotiateFormat() is called by 1 function(s): Negotiate.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free