Home / Function/ New() — gin Function Reference

New() — gin Function Reference

Architecture documentation for the New() function in gin.go from the gin codebase.

Entity Profile

Dependency Diagram

graph TD
  e28f44a6_038b_50db_1ceb_92363c2f5912["New()"]
  22068897_9e6c_d28e_6b96_439ffa67fe6e["gin.go"]
  e28f44a6_038b_50db_1ceb_92363c2f5912 -->|defined in| 22068897_9e6c_d28e_6b96_439ffa67fe6e
  style e28f44a6_038b_50db_1ceb_92363c2f5912 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

gin.go lines 202–233

func New(opts ...OptionFunc) *Engine {
	debugPrintWARNINGNew()
	engine := &Engine{
		RouterGroup: RouterGroup{
			Handlers: nil,
			basePath: "/",
			root:     true,
		},
		FuncMap:                template.FuncMap{},
		RedirectTrailingSlash:  true,
		RedirectFixedPath:      false,
		HandleMethodNotAllowed: false,
		ForwardedByClientIP:    true,
		RemoteIPHeaders:        []string{"X-Forwarded-For", "X-Real-IP"},
		TrustedPlatform:        defaultPlatform,
		UseRawPath:             false,
		UseEscapedPath:         false,
		RemoveExtraSlash:       false,
		UnescapePathValues:     true,
		MaxMultipartMemory:     defaultMultipartMemory,
		trees:                  make(methodTrees, 0, 9),
		delims:                 render.Delims{Left: "{{", Right: "}}"},
		secureJSONPrefix:       "while(1);",
		trustedProxies:         []string{"0.0.0.0/0", "::/0"},
		trustedCIDRs:           defaultTrustedCIDRs,
	}
	engine.engine = engine
	engine.pool.New = func() any {
		return engine.allocateContext(engine.maxParams)
	}
	return engine.With(opts...)
}

Domain

Subdomains

Defined In

Frequently Asked Questions

What does New() do?
New() is a function in the gin codebase, defined in gin.go.
Where is New() defined?
New() is defined in gin.go at line 202.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free