handleHTTPRequest() — gin Function Reference
Architecture documentation for the handleHTTPRequest() function in gin.go from the gin codebase.
Entity Profile
Dependency Diagram
graph TD 466cd829_a704_bc42_f2bb_a07bb48488bd["handleHTTPRequest()"] ad688401_fa47_7785_93aa_339d349cdca0["ServeHTTP()"] ad688401_fa47_7785_93aa_339d349cdca0 -->|calls| 466cd829_a704_bc42_f2bb_a07bb48488bd 7f04083b_44bc_0ddd_54e2_4a519cf2f69d["HandleContext()"] 7f04083b_44bc_0ddd_54e2_4a519cf2f69d -->|calls| 466cd829_a704_bc42_f2bb_a07bb48488bd a3ad729e_6252_c42c_5a77_556e798082aa["redirectTrailingSlash()"] 466cd829_a704_bc42_f2bb_a07bb48488bd -->|calls| a3ad729e_6252_c42c_5a77_556e798082aa 80b1d193_8c18_8a4b_2f6c_ba930413c631["redirectFixedPath()"] 466cd829_a704_bc42_f2bb_a07bb48488bd -->|calls| 80b1d193_8c18_8a4b_2f6c_ba930413c631 9cdfdbc5_2c30_179c_9d78_3d3c69afdedc["serveError()"] 466cd829_a704_bc42_f2bb_a07bb48488bd -->|calls| 9cdfdbc5_2c30_179c_9d78_3d3c69afdedc style 466cd829_a704_bc42_f2bb_a07bb48488bd fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
gin.go lines 690–760
func (engine *Engine) handleHTTPRequest(c *Context) {
httpMethod := c.Request.Method
rPath := c.Request.URL.Path
unescape := false
if engine.UseEscapedPath {
rPath = c.Request.URL.EscapedPath()
unescape = engine.UnescapePathValues
} else if engine.UseRawPath && len(c.Request.URL.RawPath) > 0 {
rPath = c.Request.URL.RawPath
unescape = engine.UnescapePathValues
}
if engine.RemoveExtraSlash {
rPath = cleanPath(rPath)
}
// Find root of the tree for the given HTTP method
t := engine.trees
for i, tl := 0, len(t); i < tl; i++ {
if t[i].method != httpMethod {
continue
}
root := t[i].root
// Find route in tree
value := root.getValue(rPath, c.params, c.skippedNodes, unescape)
if value.params != nil {
c.Params = *value.params
}
if value.handlers != nil {
c.handlers = value.handlers
c.fullPath = value.fullPath
c.Next()
c.writermem.WriteHeaderNow()
return
}
if httpMethod != http.MethodConnect && rPath != "/" {
if value.tsr && engine.RedirectTrailingSlash {
redirectTrailingSlash(c)
return
}
if engine.RedirectFixedPath && redirectFixedPath(c, root, engine.RedirectFixedPath) {
return
}
}
break
}
if engine.HandleMethodNotAllowed && len(t) > 0 {
// According to RFC 7231 section 6.5.5, MUST generate an Allow header field in response
// containing a list of the target resource's currently supported methods.
allowed := make([]string, 0, len(t)-1)
for _, tree := range engine.trees {
if tree.method == httpMethod {
continue
}
if value := tree.root.getValue(rPath, nil, c.skippedNodes, unescape); value.handlers != nil {
allowed = append(allowed, tree.method)
}
}
if len(allowed) > 0 {
c.handlers = engine.allNoMethod
c.writermem.Header().Set("Allow", strings.Join(allowed, ", "))
serveError(c, http.StatusMethodNotAllowed, default405Body)
return
}
}
c.handlers = engine.allNoRoute
serveError(c, http.StatusNotFound, default404Body)
}
Domain
Subdomains
Called By
Source
Frequently Asked Questions
What does handleHTTPRequest() do?
handleHTTPRequest() is a function in the gin codebase.
What does handleHTTPRequest() call?
handleHTTPRequest() calls 3 function(s): redirectFixedPath, redirectTrailingSlash, serveError.
What calls handleHTTPRequest()?
handleHTTPRequest() is called by 2 function(s): HandleContext, ServeHTTP.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free