From 8b5b6b116a1fc8ab1cd19f70799c7999ef031255 Mon Sep 17 00:00:00 2001 From: kataras Date: Wed, 23 Aug 2017 15:26:46 +0300 Subject: [PATCH] add a nested parties and wildcard subdomains test Former-commit-id: c2faa1bd02935ef13c32027f99c097b5c60babef --- _examples/routing/main.go | 30 ++++++++++++++++++++++++++++++ _examples/routing/main_test.go | 7 +++++++ 2 files changed, 37 insertions(+) diff --git a/_examples/routing/main.go b/_examples/routing/main.go index 31d3c4fc..edb76828 100644 --- a/_examples/routing/main.go +++ b/_examples/routing/main.go @@ -55,6 +55,32 @@ func registerGamesRoutes(app *iris.Application) { games.Post("/{gameID:int}/clans/{clanPublicID:int}/memberships/delete", h) games.Post("/{gameID:int}/clans/{clanPublicID:int}/memberships/promote", h) games.Post("/{gameID:int}/clans/{clanPublicID:int}/memberships/demote", h) + + gamesCh := games.Party("/challenge") + { + // games/challenge + gamesCh.Get("/", h) + + gamesChBeginner := gamesCh.Party("/beginner") + { + // games/challenge/beginner/start + gamesChBeginner.Get("/start", h) + levelBeginner := gamesChBeginner.Party("/level") + { + // games/challenge/beginner/level/first + levelBeginner.Get("/first", h) + } + } + + gamesChIntermediate := gamesCh.Party("/intermediate") + { + // games/challenge/intermediate + gamesChIntermediate.Get("/", h) + // games/challenge/intermediate/start + gamesChIntermediate.Get("/start", h) + } + } + } } @@ -62,6 +88,10 @@ func registerSubdomains(app *iris.Application) { mysubdomain := app.Party("mysubdomain.") // http://mysubdomain.myhost.com mysubdomain.Get("/", h) + + willdcardSubdomain := app.Party("*.") + willdcardSubdomain.Get("/", h) + willdcardSubdomain.Party("/party").Get("/", h) } func newApp() *iris.Application { diff --git a/_examples/routing/main_test.go b/_examples/routing/main_test.go index 1613cf7e..71b6143d 100644 --- a/_examples/routing/main_test.go +++ b/_examples/routing/main_test.go @@ -81,7 +81,14 @@ func TestRouting(t *testing.T) { newTroute("GET", "", "/games/{gameID}/clans", httptest.StatusOK, "gameID", "42"), newTroute("GET", "", "/games/{gameID}/clans/clan/{clanPublicID}", httptest.StatusOK, "gameID", "42", "clanPublicID", "93"), newTroute("GET", "", "/games/{gameID}/clans/search", httptest.StatusOK, "gameID", "42"), + newTroute("GET", "", "/games/challenge", httptest.StatusOK), + newTroute("GET", "", "/games/challenge/beginner/start", httptest.StatusOK), + newTroute("GET", "", "/games/challenge/beginner/level/first", httptest.StatusOK), + newTroute("GET", "", "/games/challenge/intermediate", httptest.StatusOK), + newTroute("GET", "", "/games/challenge/intermediate/start", httptest.StatusOK), newTroute("GET", "mysubdomain", "/", httptest.StatusOK), + newTroute("GET", "mywildcardsubdomain", "/", httptest.StatusOK), + newTroute("GET", "mywildcardsubdomain", "/party", httptest.StatusOK), // PUT newTroute("PUT", "", "/games/{gameID}/players/{clanPublicID}", httptest.StatusOK, "gameID", "42", "clanPublicID", "93"), newTroute("PUT", "", "/games/{gameID}/clans/clan/{clanPublicID}", httptest.StatusOK, "gameID", "42", "clanPublicID", "93"),