1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 18:37:05 +00:00
Former-commit-id: 292d155c877ba3f9d1210db54c3df3fedd1d0c1c
This commit is contained in:
Gerasimos (Makis) Maropoulos
2018-01-15 00:54:01 +02:00
parent ad9c76adb3
commit a19e570c8a
19 changed files with 154 additions and 47 deletions

View File

@@ -119,6 +119,12 @@ func newApp() *iris.Application {
ctx.Write(b)
})
app.HandleMany("POST PUT", "/postvalue", func(ctx iris.Context) {
name := ctx.PostValueDefault("name", "iris")
headervale := ctx.GetHeader("headername")
ctx.Writef("Hello %s | %s", name, headervale)
})
return app
}
@@ -152,11 +158,13 @@ func main() {
http://mysubdomain.localhost:8080/
// PUT
http://localhost:8080/postvalue
http://localhost:8080/games/42/players/93
http://localhost:8080/games/42/clans/clan/93
// POST
http://localhost:8080/
http://localhost:8080/postvalue
http://localhost:8080/games/42/clans
http://localhost:8080/games/42/players
http://localhost:8080/games/42/clans/93/leave

View File

@@ -129,4 +129,13 @@ func TestRouting(t *testing.T) {
// test with larger body sent and wait for the custom response
largerBSent := make([]byte, maxBodySize+1, maxBodySize+1)
e.POST("/").WithBytes(largerBSent).Expect().Status(httptest.StatusBadRequest).Body().Equal("http: request body too large")
// test the post value (both post and put) and headers.
e.PUT("/postvalue").WithFormField("name", "test_put").
WithHeader("headername", "headervalue_put").Expect().
Status(httptest.StatusOK).Body().Equal("Hello test_put | headervalue_put")
e.POST("/postvalue").WithFormField("name", "test_post").
WithHeader("headername", "headervalue_post").Expect().
Status(httptest.StatusOK).Body().Equal("Hello test_post | headervalue_post")
}