func NewWithConfig(c *engine.Config) (s *Server) { s = &Server{ Server: &fasthttp.Server{ ReadTimeout: c.ReadTimeout, WriteTimeout: c.WriteTimeout, MaxConnsPerIP: c.MaxConnsPerIP, MaxRequestsPerConn: c.MaxRequestsPerConn, MaxRequestBodySize: c.MaxRequestBodySize, }, config: c, pool: &pool{ request: sync.Pool{ New: func() interface{} { return &Request{} }, }, response: sync.Pool{ New: func() interface{} { return &Response{logger: s.logger} }, }, requestHeader: sync.Pool{ New: func() interface{} { return &RequestHeader{} }, }, responseHeader: sync.Pool{ New: func() interface{} { return &ResponseHeader{} }, }, url: sync.Pool{ New: func() interface{} { return &URL{} }, }, }, handler: engine.ClearHandler(engine.HandlerFunc(func(req engine.Request, res engine.Response) { s.logger.Error("handler not set, use `SetHandler()` to set it.") })), logger: log.GetLogger("echo"), } s.Handler = s.ServeHTTP return }
func NewWithContext(fn func(*Echo) Context) (e *Echo) { e = &Echo{maxParam: new(int)} e.pool.New = func() interface{} { return fn(e) } e.router = NewRouter(e) //---------- // Defaults //---------- e.SetHTTPErrorHandler(e.DefaultHTTPErrorHandler) e.SetBinder(&binder{Echo: e}) // Logger e.logger = log.GetLogger("echo") return }