utils.go — gin Source File
Architecture documentation for utils.go, a go file in the gin codebase. 1 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 5bca33d6_0728_cd3b_708c_a59f93f5d952["utils.go"] 50f09d07_ac8c_822a_71ca_5e6dc38887ef["xml"] 5bca33d6_0728_cd3b_708c_a59f93f5d952 --> 50f09d07_ac8c_822a_71ca_5e6dc38887ef style 5bca33d6_0728_cd3b_708c_a59f93f5d952 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
// Copyright 2014 Manu Martinez-Almeida. All rights reserved.
// Use of this source code is governed by a MIT style
// license that can be found in the LICENSE file.
package gin
import (
"encoding/xml"
"math"
"net/http"
"os"
"path"
"reflect"
"runtime"
"strings"
"unicode"
)
// BindKey indicates a default bind key.
const BindKey = "_gin-gonic/gin/bindkey"
// localhostIP indicates the default localhost IP address.
const localhostIP = "127.0.0.1"
// localhostIPv6 indicates the default localhost IPv6 address.
const localhostIPv6 = "::1"
// Bind is a helper function for given interface object and returns a Gin middleware.
func Bind(val any) HandlerFunc {
value := reflect.ValueOf(val)
if value.Kind() == reflect.Ptr {
panic(`Bind struct can not be a pointer. Example:
Use: gin.Bind(Struct{}) instead of gin.Bind(&Struct{})
`)
}
typ := value.Type()
return func(c *Context) {
obj := reflect.New(typ).Interface()
if c.Bind(obj) == nil {
c.Set(BindKey, obj)
}
}
}
// WrapF is a helper function for wrapping http.HandlerFunc and returns a Gin middleware.
func WrapF(f http.HandlerFunc) HandlerFunc {
return func(c *Context) {
f(c.Writer, c.Request)
}
}
// WrapH is a helper function for wrapping http.Handler and returns a Gin middleware.
func WrapH(h http.Handler) HandlerFunc {
return func(c *Context) {
h.ServeHTTP(c.Writer, c.Request)
}
}
// H is a shortcut for map[string]any
// ... (128 more lines)
Domain
Subdomains
Functions
Dependencies
- xml
Source
Frequently Asked Questions
What does utils.go do?
utils.go is a source file in the gin codebase, written in go. It belongs to the GinCore domain, Middleware subdomain.
What functions are defined in utils.go?
utils.go defines 14 function(s): Bind, WrapF, WrapH, assert1, chooseData, filterFlags, isASCII, joinPaths, lastChar, nameOfFunction, and 4 more.
What does utils.go depend on?
utils.go imports 1 module(s): xml.
Where is utils.go in the architecture?
utils.go is located at utils.go (domain: GinCore, subdomain: Middleware).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free