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

Function NewContext

context.go:98–107  ·  view source on GitHub ↗

NewContext returns a new Context instance. Note: request,response and e can be left to nil as Echo.ServeHTTP will call c.Reset(req,resp) anyway these arguments are useful when creating context for tests and cases like that.

(r *http.Request, w http.ResponseWriter, opts ...any)

Source from the content-addressed store, hash-verified

96// Note: request,response and e can be left to nil as Echo.ServeHTTP will call c.Reset(req,resp) anyway
97// these arguments are useful when creating context for tests and cases like that.
98func NewContext(r *http.Request, w http.ResponseWriter, opts ...any) *Context {
99 var e *Echo
100 for _, opt := range opts {
101 switch v := opt.(type) {
102 case *Echo:
103 e = v
104 }
105 }
106 return newContext(r, w, e)
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.

Callers 15

TestContextHTMLFunction · 0.85
TestContextHTMLBlobFunction · 0.85
TestContext_SchemeFunction · 0.85
TestContextGetOKFunction · 0.85
TestContextGetOrOKFunction · 0.85
TestPathParamFunction · 0.85
TestQueryParamFunction · 0.85

Calls 1

newContextFunction · 0.85

Tested by 15

TestContextHTMLFunction · 0.68
TestContextHTMLBlobFunction · 0.68
TestContext_SchemeFunction · 0.68
TestContextGetOKFunction · 0.68
TestContextGetOrOKFunction · 0.68
TestPathParamFunction · 0.68
TestQueryParamFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…