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)
| 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. |
| 98 | func 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 | |
| 109 | func 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. |
searching dependent graphs…