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
  b515911f_03f8_e2c6_786f_7201a9da082c["New()"]
  d5ddf90e_9fda_0dfc_330c_c77443e92906["allocateContext()"]
  b515911f_03f8_e2c6_786f_7201a9da082c -->|calls| d5ddf90e_9fda_0dfc_330c_c77443e92906
  style b515911f_03f8_e2c6_786f_7201a9da082c 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

Frequently Asked Questions

What does New() do?
New() is a function in the gin codebase.
What does New() call?
New() calls 1 function(s): allocateContext.

Analyze Your Own Codebase

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

Try Supermodel Free