func NewConfig(c *engine.Config) (s *Server) { s = &Server{ Server: new(http.Server), config: c, pool: &Pool{ request: sync.Pool{ New: func() interface{} { return &Request{} }, }, response: sync.Pool{ New: func() interface{} { return &Response{logger: s.logger} }, }, header: sync.Pool{ New: func() interface{} { return &Header{} }, }, url: sync.Pool{ New: func() interface{} { return &URL{} }, }, }, handler: engine.HandlerFunc(func(req engine.Request, res engine.Response) { panic("vodka: handler not set, use `Server#SetHandler()` to set it.") }), logger: log.New("vodka"), } return }
// TODO: Fix me func TestServer(t *testing.T) { s := New("") s.SetHandler(engine.HandlerFunc(func(req engine.Request, res engine.Response) { })) ctx := new(fasthttp.RequestCtx) s.ServeHTTP(ctx) }
// TODO: Fix me func TestServer(t *testing.T) { s := New("") s.SetHandler(engine.HandlerFunc(func(req engine.Request, res engine.Response) { })) rec := httptest.NewRecorder() req := new(http.Request) s.ServeHTTP(rec, req) }
// WithConfig returns `Server` instance with provided config. func WithConfig(c engine.Config) (s *Server) { s = &Server{ Server: new(http.Server), config: c, pool: &pool{ request: sync.Pool{ New: func() interface{} { return &Request{logger: s.logger} }, }, response: sync.Pool{ New: func() interface{} { return &Response{logger: s.logger} }, }, responseAdapter: sync.Pool{ New: func() interface{} { return &responseAdapter{} }, }, header: sync.Pool{ New: func() interface{} { return &Header{} }, }, url: sync.Pool{ New: func() interface{} { return &URL{} }, }, }, handler: engine.HandlerFunc(func(req engine.Request, res engine.Response) { panic("vodka: handler not set, use `Server#SetHandler()` to set it.") }), logger: glog.New("vodka"), } s.ReadTimeout = c.ReadTimeout s.WriteTimeout = c.WriteTimeout s.Addr = c.Address s.Handler = s return }