-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Former-commit-id: 3e214ab6b6da4d1c6e4a66180a4ccfa61c0879ae
- Loading branch information
Showing
15 changed files
with
362 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
12.1.6:https://github.com/kataras/iris/releases/tag/v12.1.6 | ||
12.1.7:https://github.com/kataras/iris/releases/tag/v12.1.7 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package main | ||
|
||
import "github.com/kataras/iris/v12" | ||
|
||
func main() { | ||
app := newApp() | ||
// Navigate through https://github.com/kataras/iris/issues/1448 for details. | ||
// | ||
// GET: http://localhost:8080 | ||
// POST, PUT, DELETE, CONNECT, HEAD, PATCH, OPTIONS, TRACE : http://localhost:8080 | ||
app.Listen(":8080") | ||
} | ||
|
||
func newApp() *iris.Application { | ||
app := iris.New() | ||
// Skip and do NOT override existing regitered route, continue normally. | ||
// Applies to a Party and its children, in this case the whole application's routes. | ||
app.SetRegisterRule(iris.RouteSkip) | ||
|
||
/* Read also: | ||
// The default behavior, will override the getHandler to anyHandler on `app.Any` call. | ||
app.SetRegistRule(iris.RouteOverride) | ||
// Stops the execution and fires an error before server boot. | ||
app.SetRegisterRule(iris.RouteError) | ||
*/ | ||
|
||
app.Get("/", getHandler) | ||
// app.Any does NOT override the previous GET route because of `iris.RouteSkip` rule. | ||
app.Any("/", anyHandler) | ||
|
||
return app | ||
} | ||
|
||
func getHandler(ctx iris.Context) { | ||
ctx.Writef("From %s", ctx.GetCurrentRoute().Trace()) | ||
} | ||
|
||
func anyHandler(ctx iris.Context) { | ||
ctx.Writef("From %s", ctx.GetCurrentRoute().Trace()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package main | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/kataras/iris/v12/core/router" | ||
"github.com/kataras/iris/v12/httptest" | ||
) | ||
|
||
func TestRouteRegisterRuleExample(t *testing.T) { | ||
app := newApp() | ||
e := httptest.New(t, app) | ||
|
||
for _, method := range router.AllMethods { | ||
tt := e.Request(method, "/").Expect().Status(httptest.StatusOK).Body() | ||
if method == "GET" { | ||
tt.Equal("From [./main.go:28] GET: / -> github.com/kataras/iris/v12/_examples/routing/route-register-rule.getHandler()") | ||
} else { | ||
tt.Equal("From [./main.go:30] " + method + ": / -> github.com/kataras/iris/v12/_examples/routing/route-register-rule.anyHandler()") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,55 @@ | ||
<a href="{{urlpath "my-page1"}}">/mypath</a> | ||
<br /> | ||
<br /> | ||
|
||
<a href="{{urlpath "my-page2" "theParam1" "theParam2"}}">/mypath2/{paramfirst}/{paramsecond}</a> | ||
<br /> | ||
<br /> | ||
|
||
<a href="{{urlpath "my-page3" "theParam1" "theParam2AfterStatic"}}">/mypath3/{paramfirst}/statichere/{paramsecond}</a> | ||
<br /> | ||
<br /> | ||
|
||
<a href="{{urlpath "my-page4" "theParam1" "theparam2AfterStatic" "otherParam" "matchAnything"}}"> | ||
/mypath4/{paramfirst}/statichere/{paramsecond}/{otherparam}/{something:path}</a> | ||
<br /> | ||
<br /> | ||
|
||
<a href="{{urlpath "my-page5" "theParam1" "theParam2Afterstatichere" "otherParam" "matchAnythingAfterStatic"}}"> | ||
/mypath5/{paramfirst}/statichere/{paramsecond}/{otherparam}/anything/{anything:path}</a> | ||
<br /> | ||
<br /> | ||
|
||
<a href={{urlpath "my-page6" .ParamsAsArray }}> | ||
/mypath6/{paramfirst}/{paramsecond}/statichere/{paramThirdAfterStatic} | ||
</a> | ||
<html> | ||
|
||
<head> | ||
<title>template_html_3</title> | ||
<style> | ||
a { | ||
color: #0f7afc; | ||
border-bottom-color: rgba(15, 122, 252, 0.2); | ||
text-decoration: none | ||
} | ||
|
||
a:hover { | ||
color: #cf0000; | ||
border-bottom-color: rgba(208, 64, 0, 0.2); | ||
text-decoration: none | ||
} | ||
|
||
a:visited { | ||
color: #800080; | ||
border-bottom-color: rgba(128, 0, 128, 0.2); | ||
text-decoration: none | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
|
||
<a href="{{urlpath "my-page1"}}">/mypath</a> | ||
<br /> | ||
<br /> | ||
|
||
<a href="{{urlpath "my-page2" "theParam1" "theParam2"}}">/mypath2/{paramfirst}/{paramsecond}</a> | ||
<br /> | ||
<br /> | ||
|
||
<a href="{{urlpath "my-page3" "theParam1" "theParam2AfterStatic"}}">/mypath3/{paramfirst}/statichere/{paramsecond}</a> | ||
<br /> | ||
<br /> | ||
|
||
<a href="{{urlpath "my-page4" "theParam1" "theparam2AfterStatic" "otherParam" "matchAnything"}}"> | ||
/mypath4/{paramfirst}/statichere/{paramsecond}/{otherparam}/{something:path}</a> | ||
<br /> | ||
<br /> | ||
|
||
<a href="{{urlpath "my-page5" "theParam1" "theParam2Afterstatichere" "otherParam" "matchAnythingAfterStatic"}}"> | ||
/mypath5/{paramfirst}/statichere/{paramsecond}/{otherparam}/anything/{anything:path}</a> | ||
<br /> | ||
<br /> | ||
|
||
<a href={{urlpath "my-page6" .ParamsAsArray }}> | ||
/mypath6/{paramfirst}/{paramsecond}/statichere/{paramThirdAfterStatic} | ||
</a> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.