mirror of
https://github.com/labstack/echo.git
synced 2025-01-26 03:20:08 +02:00
GAE fix
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
parent
d5ba76ed81
commit
8916d5558c
9
echo.go
9
echo.go
@ -142,6 +142,7 @@ const (
|
||||
WWWAuthenticate = "WWW-Authenticate"
|
||||
XForwardedFor = "X-Forwarded-For"
|
||||
XRealIP = "X-Real-IP"
|
||||
|
||||
//-----------
|
||||
// Protocols
|
||||
//-----------
|
||||
@ -207,12 +208,12 @@ func New() (e *Echo) {
|
||||
return
|
||||
}
|
||||
|
||||
func (f MiddlewareFunc) Handle(h Handler) Handler {
|
||||
return f(h)
|
||||
func (m MiddlewareFunc) Handle(h Handler) Handler {
|
||||
return m(h)
|
||||
}
|
||||
|
||||
func (f HandlerFunc) Handle(c Context) error {
|
||||
return f(c)
|
||||
func (h HandlerFunc) Handle(c Context) error {
|
||||
return h(c)
|
||||
}
|
||||
|
||||
// Router returns router.
|
||||
|
@ -67,7 +67,7 @@ func NewConfig(c *engine.Config) (s *Server) {
|
||||
},
|
||||
},
|
||||
handler: func(req engine.Request, res engine.Response) {
|
||||
s.logger.Warn("handler not set")
|
||||
s.logger.Fatal("handler not set")
|
||||
},
|
||||
logger: log.New("echo"),
|
||||
}
|
||||
@ -84,30 +84,7 @@ func (s *Server) SetLogger(l logger.Logger) {
|
||||
|
||||
func (s *Server) Start() {
|
||||
s.Addr = s.config.Address
|
||||
s.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
|
||||
// Request
|
||||
req := s.pool.request.Get().(*Request)
|
||||
reqHdr := s.pool.header.Get().(*Header)
|
||||
reqURL := s.pool.url.Get().(*URL)
|
||||
reqHdr.reset(r.Header)
|
||||
reqURL.reset(r.URL)
|
||||
req.reset(r, reqHdr, reqURL)
|
||||
|
||||
// Response
|
||||
res := s.pool.response.Get().(*Response)
|
||||
resHdr := s.pool.header.Get().(*Header)
|
||||
resHdr.reset(w.Header())
|
||||
res.reset(w, resHdr)
|
||||
|
||||
s.handler(req, res)
|
||||
|
||||
s.pool.request.Put(req)
|
||||
s.pool.header.Put(reqHdr)
|
||||
s.pool.url.Put(reqURL)
|
||||
s.pool.response.Put(res)
|
||||
s.pool.header.Put(resHdr)
|
||||
})
|
||||
|
||||
s.Handler = s
|
||||
certfile := s.config.TLSCertfile
|
||||
keyfile := s.config.TLSKeyfile
|
||||
if certfile != "" && keyfile != "" {
|
||||
@ -116,3 +93,27 @@ func (s *Server) Start() {
|
||||
s.logger.Fatal(s.ListenAndServe())
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
// Request
|
||||
req := s.pool.request.Get().(*Request)
|
||||
reqHdr := s.pool.header.Get().(*Header)
|
||||
reqURL := s.pool.url.Get().(*URL)
|
||||
reqHdr.reset(r.Header)
|
||||
reqURL.reset(r.URL)
|
||||
req.reset(r, reqHdr, reqURL)
|
||||
|
||||
// Response
|
||||
res := s.pool.response.Get().(*Response)
|
||||
resHdr := s.pool.header.Get().(*Header)
|
||||
resHdr.reset(w.Header())
|
||||
res.reset(w, resHdr)
|
||||
|
||||
s.handler(req, res)
|
||||
|
||||
s.pool.request.Put(req)
|
||||
s.pool.header.Put(reqHdr)
|
||||
s.pool.url.Put(reqURL)
|
||||
s.pool.response.Put(res)
|
||||
s.pool.header.Put(resHdr)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user