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

Function New

echo.go:371–390  ·  view source on GitHub ↗

New creates an instance of Echo.

()

Source from the content-addressed store, hash-verified

369
370// New creates an instance of Echo.
371func New() *Echo {
372 dir, _ := os.Getwd()
373 logger := slog.New(slog.NewJSONHandler(os.Stdout, nil))
374 e := &Echo{
375 Logger: logger,
376 Filesystem: NewDefaultFS(dir),
377 Binder: &DefaultBinder{},
378 JSONSerializer: &DefaultJSONSerializer{},
379 formParseMaxMemory: defaultMemory,
380 }
381
382 e.serveHTTPFunc = e.serveHTTP
383 e.router = NewRouter(RouterConfig{})
384 e.HTTPErrorHandler = DefaultHTTPErrorHandler(false)
385 e.contextPool.New = func() any {
386 return newContext(nil, nil, e)
387 }
388 e.buildRouterChains()
389 return e
390}
391
392// buildRouterChains compiles the global and pre-middleware chains once so that ServeHTTP does not have to
393// re-wrap middleware closures on every request. It must be called whenever e.middleware or e.premiddleware

Callers 15

BenchmarkAllocJSONPFunction · 0.85
BenchmarkAllocJSONFunction · 0.85
BenchmarkAllocXMLFunction · 0.85
TestContextEchoFunction · 0.85
TestContextRequestFunction · 0.85
TestContextResponseFunction · 0.85
TestContextStreamFunction · 0.85
TestContextJSONFunction · 0.85
TestContextJSONErrorsOutFunction · 0.85

Calls 5

buildRouterChainsMethod · 0.95
NewDefaultFSFunction · 0.85
NewRouterFunction · 0.85
DefaultHTTPErrorHandlerFunction · 0.85
newContextFunction · 0.85

Tested by 15

BenchmarkAllocJSONPFunction · 0.68
BenchmarkAllocJSONFunction · 0.68
BenchmarkAllocXMLFunction · 0.68
TestContextEchoFunction · 0.68
TestContextRequestFunction · 0.68
TestContextResponseFunction · 0.68
TestContextStreamFunction · 0.68
TestContextJSONFunction · 0.68
TestContextJSONErrorsOutFunction · 0.68