mirror of
https://github.com/labstack/echo.git
synced 2025-11-25 22:32:23 +02:00
removed embedded context and exposed SetRequest in context
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
@@ -281,7 +281,7 @@ func TestRouterStatic(t *testing.T) {
|
||||
c.Set("path", path)
|
||||
return nil
|
||||
}, e)
|
||||
c := e.NewContext(nil, nil).(*echoContext)
|
||||
c := e.NewContext(nil, nil).(*context)
|
||||
r.Find(GET, path, c)
|
||||
c.handler(c)
|
||||
assert.Equal(t, path, c.Get("path"))
|
||||
@@ -293,7 +293,7 @@ func TestRouterParam(t *testing.T) {
|
||||
r.Add(GET, "/users/:id", func(c Context) error {
|
||||
return nil
|
||||
}, e)
|
||||
c := e.NewContext(nil, nil).(*echoContext)
|
||||
c := e.NewContext(nil, nil).(*context)
|
||||
r.Find(GET, "/users/1", c)
|
||||
assert.Equal(t, "1", c.P(0))
|
||||
}
|
||||
@@ -304,7 +304,7 @@ func TestRouterTwoParam(t *testing.T) {
|
||||
r.Add(GET, "/users/:uid/files/:fid", func(Context) error {
|
||||
return nil
|
||||
}, e)
|
||||
c := e.NewContext(nil, nil).(*echoContext)
|
||||
c := e.NewContext(nil, nil).(*context)
|
||||
|
||||
r.Find(GET, "/users/1/files/1", c)
|
||||
assert.Equal(t, "1", c.P(0))
|
||||
@@ -324,7 +324,7 @@ func TestRouterParamWithSlash(t *testing.T) {
|
||||
return nil
|
||||
}, e)
|
||||
|
||||
c := e.NewContext(nil, nil).(*echoContext)
|
||||
c := e.NewContext(nil, nil).(*context)
|
||||
assert.NotPanics(t, func() {
|
||||
r.Find(GET, "/a/1/c/d/2/3", c)
|
||||
})
|
||||
@@ -344,7 +344,7 @@ func TestRouterMatchAny(t *testing.T) {
|
||||
r.Add(GET, "/users/*", func(Context) error {
|
||||
return nil
|
||||
}, e)
|
||||
c := e.NewContext(nil, nil).(*echoContext)
|
||||
c := e.NewContext(nil, nil).(*context)
|
||||
|
||||
r.Find(GET, "/", c)
|
||||
assert.Equal(t, "", c.P(0))
|
||||
@@ -362,7 +362,7 @@ func TestRouterMicroParam(t *testing.T) {
|
||||
r.Add(GET, "/:a/:b/:c", func(c Context) error {
|
||||
return nil
|
||||
}, e)
|
||||
c := e.NewContext(nil, nil).(*echoContext)
|
||||
c := e.NewContext(nil, nil).(*context)
|
||||
r.Find(GET, "/1/2/3", c)
|
||||
assert.Equal(t, "1", c.P(0))
|
||||
assert.Equal(t, "2", c.P(1))
|
||||
@@ -377,7 +377,7 @@ func TestRouterMixParamMatchAny(t *testing.T) {
|
||||
r.Add(GET, "/users/:id/*", func(c Context) error {
|
||||
return nil
|
||||
}, e)
|
||||
c := e.NewContext(nil, nil).(*echoContext)
|
||||
c := e.NewContext(nil, nil).(*context)
|
||||
|
||||
r.Find(GET, "/users/joe/comments", c)
|
||||
c.handler(c)
|
||||
@@ -396,7 +396,7 @@ func TestRouterMultiRoute(t *testing.T) {
|
||||
r.Add(GET, "/users/:id", func(c Context) error {
|
||||
return nil
|
||||
}, e)
|
||||
c := e.NewContext(nil, nil).(*echoContext)
|
||||
c := e.NewContext(nil, nil).(*context)
|
||||
|
||||
// Route > /users
|
||||
r.Find(GET, "/users", c)
|
||||
@@ -408,7 +408,7 @@ func TestRouterMultiRoute(t *testing.T) {
|
||||
assert.Equal(t, "1", c.P(0))
|
||||
|
||||
// Route > /user
|
||||
c = e.NewContext(nil, nil).(*echoContext)
|
||||
c = e.NewContext(nil, nil).(*context)
|
||||
r.Find(GET, "/user", c)
|
||||
he := c.handler(c).(*HTTPError)
|
||||
assert.Equal(t, http.StatusNotFound, he.Code)
|
||||
@@ -447,7 +447,7 @@ func TestRouterPriority(t *testing.T) {
|
||||
c.Set("g", 7)
|
||||
return nil
|
||||
}, e)
|
||||
c := e.NewContext(nil, nil).(*echoContext)
|
||||
c := e.NewContext(nil, nil).(*context)
|
||||
|
||||
// Route > /users
|
||||
r.Find(GET, "/users", c)
|
||||
@@ -490,7 +490,7 @@ func TestRouterPriority(t *testing.T) {
|
||||
func TestRouterPriorityNotFound(t *testing.T) {
|
||||
e := New()
|
||||
r := e.router
|
||||
c := e.NewContext(nil, nil).(*echoContext)
|
||||
c := e.NewContext(nil, nil).(*context)
|
||||
|
||||
// Add
|
||||
r.Add(GET, "/a/foo", func(c Context) error {
|
||||
@@ -511,7 +511,7 @@ func TestRouterPriorityNotFound(t *testing.T) {
|
||||
c.handler(c)
|
||||
assert.Equal(t, 2, c.Get("b"))
|
||||
|
||||
c = e.NewContext(nil, nil).(*echoContext)
|
||||
c = e.NewContext(nil, nil).(*context)
|
||||
r.Find(GET, "/abc/def", c)
|
||||
he := c.handler(c).(*HTTPError)
|
||||
assert.Equal(t, http.StatusNotFound, he.Code)
|
||||
@@ -532,7 +532,7 @@ func TestRouterParamNames(t *testing.T) {
|
||||
r.Add(GET, "/users/:uid/files/:fid", func(c Context) error {
|
||||
return nil
|
||||
}, e)
|
||||
c := e.NewContext(nil, nil).(*echoContext)
|
||||
c := e.NewContext(nil, nil).(*context)
|
||||
|
||||
// Route > /users
|
||||
r.Find(GET, "/users", c)
|
||||
@@ -561,7 +561,7 @@ func TestRouterAPI(t *testing.T) {
|
||||
return nil
|
||||
}, e)
|
||||
}
|
||||
c := e.NewContext(nil, nil).(*echoContext)
|
||||
c := e.NewContext(nil, nil).(*context)
|
||||
for _, route := range api {
|
||||
r.Find(route.Method, route.Path, c)
|
||||
for i, n := range c.pnames {
|
||||
|
||||
Reference in New Issue
Block a user