ServeWithHandler serves ContextConfig with given handler and returns httptest.ResponseRecorder for response checking
(t *testing.T, handler echo.HandlerFunc, opts ...any)
| 165 | |
| 166 | // ServeWithHandler serves ContextConfig with given handler and returns httptest.ResponseRecorder for response checking |
| 167 | func (conf ContextConfig) ServeWithHandler(t *testing.T, handler echo.HandlerFunc, opts ...any) *httptest.ResponseRecorder { |
| 168 | c, rec := conf.ToContextRecorder(t) |
| 169 | |
| 170 | errHandler := echo.DefaultHTTPErrorHandler(false) |
| 171 | for _, opt := range opts { |
| 172 | switch o := opt.(type) { |
| 173 | case echo.HTTPErrorHandler: |
| 174 | errHandler = o |
| 175 | } |
| 176 | } |
| 177 | |
| 178 | err := handler(c) |
| 179 | if err != nil { |
| 180 | errHandler(c, err) |
| 181 | } |
| 182 | return rec |
| 183 | } |