1
0
mirror of https://github.com/labstack/echo.git synced 2025-12-01 22:51:17 +02:00

removed embedded context and exposed SetRequest in context

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana
2016-10-10 17:31:26 -07:00
parent 727b96f46f
commit 15eb5b0aad
8 changed files with 103 additions and 262 deletions

View File

@@ -53,7 +53,6 @@ import (
"github.com/rsc/letsencrypt"
"golang.org/x/net/context"
"golang.org/x/net/websocket"
"github.com/labstack/gommon/color"
@@ -263,10 +262,10 @@ func New() (e *Echo) {
// NewContext returns a Context instance.
func (e *Echo) NewContext(r *http.Request, w http.ResponseWriter) Context {
return &echoContext{
context: context.Background(),
return &context{
request: r,
response: NewResponse(w, e),
store: make(store),
echo: e,
pvalues: make([]string, *e.maxParam),
handler: NotFoundHandler,
@@ -486,7 +485,7 @@ func (e *Echo) ReleaseContext(c Context) {
// ServeHTTP implements `http.Handler` interface, which serves HTTP requests.
func (e *Echo) ServeHTTP(w http.ResponseWriter, r *http.Request) {
c := e.pool.Get().(*echoContext)
c := e.pool.Get().(*context)
c.Reset(r, w)
// Middleware