mirror of
https://github.com/kataras/iris.git
synced 2025-12-18 18:37:05 +00:00
Update to version 10.0.1 - read more at: https://github.com/kataras/iris/blob/master/HISTORY.md#mo-15-jenuary-2018--v1001
Former-commit-id: 292d155c877ba3f9d1210db54c3df3fedd1d0c1c
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user