MCPcopy
hub / github.com/labstack/echo / newContext

Function newContext

context.go:109–136  ·  view source on GitHub ↗
(r *http.Request, w http.ResponseWriter, e *Echo)

Source from the content-addressed store, hash-verified

107}
108
109func newContext(r *http.Request, w http.ResponseWriter, e *Echo) *Context {
110 // store is created lazily by Set and cleared (not freed) by Reset, so we deliberately do not allocate a map here.
111 c := &Context{
112 pathValues: nil,
113 echo: e,
114 logger: nil,
115 }
116 var logger *slog.Logger
117 paramLen := int32(0)
118 formParseMaxMemory := defaultMemory
119 if e != nil {
120 paramLen = e.contextPathParamAllocSize.Load()
121 logger = e.Logger
122 formParseMaxMemory = e.formParseMaxMemory
123 }
124 if logger == nil {
125 logger = slog.Default()
126 }
127 c.logger = logger
128 p := make(PathValues, 0, paramLen)
129 c.pathValues = &p
130
131 c.SetRequest(r)
132 c.orgResponse = NewResponse(w, logger)
133 c.response = c.orgResponse
134 c.formParseMaxMemory = formParseMaxMemory
135 return c
136}
137
138// Reset resets the context after request completes. It must be called along
139// with `Echo#AcquireContext()` and `Echo#ReleaseContext()`.

Callers 5

NewFunction · 0.85
NewContextMethod · 0.85
NewContextFunction · 0.85

Calls 2

SetRequestMethod · 0.95
NewResponseFunction · 0.85

Used in the wild real call sites across dependent graphs

searching dependent graphs…