Skip to content

Commit 10f280a

Browse files
committed
Update to version 12.1.7
Former-commit-id: 3e214ab6b6da4d1c6e4a66180a4ccfa61c0879ae
1 parent ea589b1 commit 10f280a

File tree

15 files changed

+362
-128
lines changed

15 files changed

+362
-128
lines changed

HISTORY.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,15 @@ Developers are not forced to upgrade if they don't really need it. Upgrade whene
2121

2222
**How to upgrade**: Open your command-line and execute this command: `go get github.com/kataras/iris/v12@latest`.
2323

24+
# Mo, 10 February 2020 | v12.1.7
25+
26+
Implement **new** `SetRegisterRule(iris.RouteOverride, RouteSkip, RouteError)` to resolve: https://github.com/kataras/iris/issues/1448
27+
28+
New Examples:
29+
30+
- [_examples/Docker](_examples/Docker)
31+
- [_examples/routing/route-register-rule](_examples/routing/route-register-rule)
32+
2433
# We, 05 February 2020 | v12.1.6
2534

2635
Fixes:

HISTORY_ES.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ Los desarrolladores no están obligados a actualizar si realmente no lo necesita
2121

2222
**Cómo actualizar**: Abra su línea de comandos y ejecute este comando: `go get github.com/kataras/iris/v12@latest`.
2323

24-
# We, 05 February 2020 | v12.1.6
24+
# Mo, 10 February 2020 | v12.1.7
2525

26-
Not translated yet, please navigate to the [english version](HISTORY.md#we-05-february-2020--v1216) instead.
26+
Not translated yet, please navigate to the [english version](HISTORY.md#mo-10-february-2020--v1217) instead.
2727

2828
# Sábado, 26 de octubre 2019 | v12.0.0
2929

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# News
22

3-
![](https://iris-go.com/images/release.png) Iris version **12.1.6** has been [released](HISTORY.md#we-05-february-2020--v1216)!
3+
![](https://iris-go.com/images/release.png) Iris version **12.1.7** has been [released](HISTORY.md#mo-10-february-2020--v1217)!
44

55
![](https://iris-go.com/images/cli.png) The official [Iris Command Line Interface](https://github.com/kataras/iris-cli) will soon be near you in 2020!
66

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
12.1.6:https://github.com/kataras/iris/releases/tag/v12.1.6
1+
12.1.7:https://github.com/kataras/iris/releases/tag/v12.1.7

_examples/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ Navigate through examples for a better understanding.
143143
- [Writing a middleware](routing/writing-a-middleware)
144144
* [per-route](routing/writing-a-middleware/per-route/main.go)
145145
* [globally](routing/writing-a-middleware/globally/main.go)
146+
- [Route Register Rule](routing/route-register-rule/main.go) **NEW**
146147

147148
### Versioning
148149

_examples/docker/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ module app
33
go 1.13
44

55
require (
6-
github.com/kataras/iris/v12 v12.1.6
6+
github.com/kataras/iris/v12 v12.1.7
77
github.com/shurcooL/sanitized_anchor_name v1.0.0 // indirect
88
)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package main
2+
3+
import "github.com/kataras/iris/v12"
4+
5+
func main() {
6+
app := newApp()
7+
// Navigate through https://github.com/kataras/iris/issues/1448 for details.
8+
//
9+
// GET: http://localhost:8080
10+
// POST, PUT, DELETE, CONNECT, HEAD, PATCH, OPTIONS, TRACE : http://localhost:8080
11+
app.Listen(":8080")
12+
}
13+
14+
func newApp() *iris.Application {
15+
app := iris.New()
16+
// Skip and do NOT override existing regitered route, continue normally.
17+
// Applies to a Party and its children, in this case the whole application's routes.
18+
app.SetRegisterRule(iris.RouteSkip)
19+
20+
/* Read also:
21+
// The default behavior, will override the getHandler to anyHandler on `app.Any` call.
22+
app.SetRegistRule(iris.RouteOverride)
23+
24+
// Stops the execution and fires an error before server boot.
25+
app.SetRegisterRule(iris.RouteError)
26+
*/
27+
28+
app.Get("/", getHandler)
29+
// app.Any does NOT override the previous GET route because of `iris.RouteSkip` rule.
30+
app.Any("/", anyHandler)
31+
32+
return app
33+
}
34+
35+
func getHandler(ctx iris.Context) {
36+
ctx.Writef("From %s", ctx.GetCurrentRoute().Trace())
37+
}
38+
39+
func anyHandler(ctx iris.Context) {
40+
ctx.Writef("From %s", ctx.GetCurrentRoute().Trace())
41+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package main
2+
3+
import (
4+
"testing"
5+
6+
"github.com/kataras/iris/v12/core/router"
7+
"github.com/kataras/iris/v12/httptest"
8+
)
9+
10+
func TestRouteRegisterRuleExample(t *testing.T) {
11+
app := newApp()
12+
e := httptest.New(t, app)
13+
14+
for _, method := range router.AllMethods {
15+
tt := e.Request(method, "/").Expect().Status(httptest.StatusOK).Body()
16+
if method == "GET" {
17+
tt.Equal("From [./main.go:28] GET: / -> github.com/kataras/iris/v12/_examples/routing/route-register-rule.getHandler()")
18+
} else {
19+
tt.Equal("From [./main.go:30] " + method + ": / -> github.com/kataras/iris/v12/_examples/routing/route-register-rule.anyHandler()")
20+
}
21+
}
22+
}
Lines changed: 55 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,55 @@
1-
<a href="{{urlpath "my-page1"}}">/mypath</a>
2-
<br />
3-
<br />
4-
5-
<a href="{{urlpath "my-page2" "theParam1" "theParam2"}}">/mypath2/{paramfirst}/{paramsecond}</a>
6-
<br />
7-
<br />
8-
9-
<a href="{{urlpath "my-page3" "theParam1" "theParam2AfterStatic"}}">/mypath3/{paramfirst}/statichere/{paramsecond}</a>
10-
<br />
11-
<br />
12-
13-
<a href="{{urlpath "my-page4" "theParam1" "theparam2AfterStatic" "otherParam" "matchAnything"}}">
14-
/mypath4/{paramfirst}/statichere/{paramsecond}/{otherparam}/{something:path}</a>
15-
<br />
16-
<br />
17-
18-
<a href="{{urlpath "my-page5" "theParam1" "theParam2Afterstatichere" "otherParam" "matchAnythingAfterStatic"}}">
19-
/mypath5/{paramfirst}/statichere/{paramsecond}/{otherparam}/anything/{anything:path}</a>
20-
<br />
21-
<br />
22-
23-
<a href={{urlpath "my-page6" .ParamsAsArray }}>
24-
/mypath6/{paramfirst}/{paramsecond}/statichere/{paramThirdAfterStatic}
25-
</a>
1+
<html>
2+
3+
<head>
4+
<title>template_html_3</title>
5+
<style>
6+
a {
7+
color: #0f7afc;
8+
border-bottom-color: rgba(15, 122, 252, 0.2);
9+
text-decoration: none
10+
}
11+
12+
a:hover {
13+
color: #cf0000;
14+
border-bottom-color: rgba(208, 64, 0, 0.2);
15+
text-decoration: none
16+
}
17+
18+
a:visited {
19+
color: #800080;
20+
border-bottom-color: rgba(128, 0, 128, 0.2);
21+
text-decoration: none
22+
}
23+
</style>
24+
</head>
25+
26+
<body>
27+
28+
<a href="{{urlpath "my-page1"}}">/mypath</a>
29+
<br />
30+
<br />
31+
32+
<a href="{{urlpath "my-page2" "theParam1" "theParam2"}}">/mypath2/{paramfirst}/{paramsecond}</a>
33+
<br />
34+
<br />
35+
36+
<a href="{{urlpath "my-page3" "theParam1" "theParam2AfterStatic"}}">/mypath3/{paramfirst}/statichere/{paramsecond}</a>
37+
<br />
38+
<br />
39+
40+
<a href="{{urlpath "my-page4" "theParam1" "theparam2AfterStatic" "otherParam" "matchAnything"}}">
41+
/mypath4/{paramfirst}/statichere/{paramsecond}/{otherparam}/{something:path}</a>
42+
<br />
43+
<br />
44+
45+
<a href="{{urlpath "my-page5" "theParam1" "theParam2Afterstatichere" "otherParam" "matchAnythingAfterStatic"}}">
46+
/mypath5/{paramfirst}/statichere/{paramsecond}/{otherparam}/anything/{anything:path}</a>
47+
<br />
48+
<br />
49+
50+
<a href={{urlpath "my-page6" .ParamsAsArray }}>
51+
/mypath6/{paramfirst}/{paramsecond}/statichere/{paramThirdAfterStatic}
52+
</a>
53+
</body>
54+
55+
</html>

context/route.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ type RouteReadOnly interface {
4343

4444
// ResolvePath returns the formatted path's %v replaced with the args.
4545
ResolvePath(args ...string) string
46+
// Trace returns some debug infos as a string sentence.
47+
// Should be called after Build.
48+
Trace() string
4649

4750
// Tmpl returns the path template,
4851
// it contains the parsed template

0 commit comments

Comments
 (0)