From 970279deb8f1dba5495db30505526b2e0471f78e Mon Sep 17 00:00:00 2001 From: "Gerasimos (Makis) Maropoulos" Date: Tue, 30 Jul 2019 18:02:02 +0300 Subject: [PATCH] minor Former-commit-id: da3ffd7b32daa12b17ad2863cb55e9d15ec9943a --- HISTORY.md | 2 +- README.md | 5 +++-- README_ZH.md | 2 +- _examples/routing/basic/main.go | 10 ++++++++-- _examples/routing/basic/main_test.go | 3 +++ _examples/routing/dynamic-path/main.go | 5 +++++ 6 files changed, 21 insertions(+), 6 deletions(-) diff --git a/HISTORY.md b/HISTORY.md index 3b7bc94e..e604938d 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -55,4 +55,4 @@ app.Get("/path", func(ctx iris.Context){ # Tu, 23 July 2019 | v11.2.0 -Read about the new release at: https://dev.to/kataras/iris-version-11-2-released-22bc +Read about the new release at: https://www.facebook.com/iris.framework/posts/3276606095684693 diff --git a/README.md b/README.md index 05985b15..f4c3a423 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Iris is a fast, simple yet fully featured and very efficient web framework for G Learn what [others say about Iris](https://iris-go.com/testimonials/) and **star** this github repository. -> Version 11.2 **released!** [Spread the news](https://dev.to/kataras/iris-version-11-2-released-22bc). +> Version 11.2 **released!** [Spread the news](https://www.facebook.com/iris.framework/posts/3276606095684693). ## Learning Iris @@ -53,9 +53,10 @@ For a more detailed technical documentation you can head over to our [godocs](ht ### Do you like to read while traveling? + Book cover + You can [request](https://bit.ly/iris-req-book) a PDF version and online access of the **E-Book** today and be participated in the development of Iris. -[![https://iris-go.com/images/iris-book-overview.png](https://iris-go.com/images/iris-book-overview.png)](https://bit.ly/iris-req-book) ## Contributing diff --git a/README_ZH.md b/README_ZH.md index f7214990..bdfb98f3 100644 --- a/README_ZH.md +++ b/README_ZH.md @@ -8,7 +8,7 @@ Iris 是基于 Go 编写的一个快速,简单但功能齐全且非常高效 看看 [其他人如何评价 Iris](https://iris-go.com/testimonials/),同时欢迎各位点亮 **star**。 -> 新版本 11.2 发布! [散布消息](https://dev.to/kataras/iris-version-11-2-released-22bc). +> 新版本 11.2 发布! [散布消息](https://www.facebook.com/iris.framework/posts/3276606095684693). ## 学习 Iris diff --git a/_examples/routing/basic/main.go b/_examples/routing/basic/main.go index df40290f..9bb530d9 100644 --- a/_examples/routing/basic/main.go +++ b/_examples/routing/basic/main.go @@ -18,8 +18,8 @@ func newApp() *iris.Application { // // Third receiver should contains the route's handler(s), they are executed by order. app.Handle("GET", "/", func(ctx iris.Context) { - // navigate to the middle of $GOPATH/src/github.com/kataras/iris/context/context.go - // to overview all context's method (there a lot of them, read that and you will learn how iris works too) + // navigate to the https://github.com/kataras/iris/wiki/Routing-context-methods + // to overview all context's method. ctx.HTML("Hello from " + ctx.Path()) // Hello from / }) @@ -28,6 +28,10 @@ func newApp() *iris.Application { }) // Different path parameters types in the same path. + app.Get("/u/{p:path}", func(ctx iris.Context) { + ctx.Writef(":string, :int, :uint, :alphabetical and :path in the same path pattern.") + }) + app.Get("/u/{username:string}", func(ctx iris.Context) { ctx.Writef("before username (string), current route name: %s\n", ctx.RouteName()) ctx.Next() @@ -57,6 +61,7 @@ func newApp() *iris.Application { }) /* + /u/some/path/here maps to :path /u/abcd maps to :alphabetical (if :alphabetical registered otherwise :string) /u/42 maps to :uint (if :uint registered otherwise :int) /u/-1 maps to :int (if :int registered otherwise :string) @@ -173,6 +178,7 @@ func main() { // http://localhost:8080/u/42 // http://localhost:8080/u/-1 // http://localhost:8080/u/abcd123 + // http://localhost:8080/u/some/path/here // // if hosts edited: // http://v1.localhost:8080 diff --git a/_examples/routing/basic/main_test.go b/_examples/routing/basic/main_test.go index e539dbe3..0f1b98cd 100644 --- a/_examples/routing/basic/main_test.go +++ b/_examples/routing/basic/main_test.go @@ -29,6 +29,7 @@ func TestRoutingBasic(t *testing.T) { expectedIndexResponse = "Hello from /" expectedHomeResponse = `Same as app.Handle("GET", "/", [...])` + expectedUpathResponse = ":string, :int, :uint, :alphabetical and :path in the same path pattern." expectedUStringResponse = expectedUResponse("username", "string", "abcd123") expectedUIntResponse = expectedUResponse("id", "int", "-1") expectedUUintResponse = expectedUResponse("uid", "uint", "42") @@ -56,6 +57,8 @@ func TestRoutingBasic(t *testing.T) { e.GET("/home").Expect().Status(httptest.StatusOK). Body().Equal(expectedHomeResponse) + e.GET("/u/some/path/here").Expect().Status(httptest.StatusOK). + Body().Equal(expectedUpathResponse) e.GET("/u/abcd123").Expect().Status(httptest.StatusOK). Body().Equal(expectedUStringResponse) e.GET("/u/-1").Expect().Status(httptest.StatusOK). diff --git a/_examples/routing/dynamic-path/main.go b/_examples/routing/dynamic-path/main.go index b1ac1510..a5f00618 100644 --- a/_examples/routing/dynamic-path/main.go +++ b/_examples/routing/dynamic-path/main.go @@ -284,5 +284,10 @@ func main() { // Last, do not confuse `ctx.Params()` with `ctx.Values()`. // Path parameter's values can be retrieved from `ctx.Params()`, // context's local storage that can be used to communicate between handlers and middleware(s) can be stored to `ctx.Values()`. + // + // When registering different parameter types in the same exact path pattern, the path parameter's name + // should differ e.g. + // /path/{name:string} + // /path/{id:uint} app.Run(iris.Addr(":8080")) }