From 8751068773a0a9016582d872c4317130d363504b Mon Sep 17 00:00:00 2001 From: BenLampson <58603432@qq.com> Date: Wed, 25 Sep 2019 16:11:39 +0800 Subject: [PATCH 1/3] Fix bug:about the MVC package route binding I found there has some little bug in the controller_method_parser.go the bug is : if someone use the code like this: func (cc *HelloWorld) GetInfoXYT() We can't create the Url that he want. We lose the T, our's url is: info/x/y Cause// it doesn't count the last uppercase and the last append is words = append(words, s[start:end]) --- mvc/controller_method_parser.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mvc/controller_method_parser.go b/mvc/controller_method_parser.go index 650a880a9d..aef3062f0b 100644 --- a/mvc/controller_method_parser.go +++ b/mvc/controller_method_parser.go @@ -51,7 +51,7 @@ func (l *methodLexer) reset(s string) { } if end > 0 && len(s) >= end { - words = append(words, s[start:end]) + words = append(words, s[start:]) } } From 146233bcc8d2125eb43dc7f9dfdb3ec7c93d77db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?BenLampson=28=E8=B5=B5=E5=85=83=E6=BA=90=29?= <58603432@qq.com> Date: Thu, 26 Sep 2019 09:07:34 +0800 Subject: [PATCH 2/3] Update controller_test.go --- mvc/controller_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/mvc/controller_test.go b/mvc/controller_test.go index 5575f421b6..49d561e163 100644 --- a/mvc/controller_test.go +++ b/mvc/controller_test.go @@ -409,6 +409,9 @@ func (c *testControllerRelPathFromFunc) GetSomethingByBy(string, int) {} func (c *testControllerRelPathFromFunc) GetSomethingNewBy(string, int) {} // two input arguments, one By which is the latest word. func (c *testControllerRelPathFromFunc) GetSomethingByElseThisBy(bool, int) {} // two input arguments +func (c *testControllerRelPathFromFunc) GetLocationX(){} +func (c *testControllerRelPathFromFunc) GetLocationXBy(int){} + func TestControllerRelPathFromFunc(t *testing.T) { app := iris.New() New(app).Handle(new(testControllerRelPathFromFunc)) From 0e1af3fef3ed478b0c4a85aa4dddb4cb42372d9c Mon Sep 17 00:00:00 2001 From: "Gerasimos (Makis) Maropoulos" Date: Sat, 5 Oct 2019 22:24:35 +0300 Subject: [PATCH 3/3] add test case for https://github.com/kataras/iris/pull/1364 --- mvc/controller_test.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mvc/controller_test.go b/mvc/controller_test.go index 49d561e163..db9acfa8b3 100644 --- a/mvc/controller_test.go +++ b/mvc/controller_test.go @@ -409,8 +409,9 @@ func (c *testControllerRelPathFromFunc) GetSomethingByBy(string, int) {} func (c *testControllerRelPathFromFunc) GetSomethingNewBy(string, int) {} // two input arguments, one By which is the latest word. func (c *testControllerRelPathFromFunc) GetSomethingByElseThisBy(bool, int) {} // two input arguments -func (c *testControllerRelPathFromFunc) GetLocationX(){} -func (c *testControllerRelPathFromFunc) GetLocationXBy(int){} +func (c *testControllerRelPathFromFunc) GetLocationX() {} +func (c *testControllerRelPathFromFunc) GetLocationXY() {} +func (c *testControllerRelPathFromFunc) GetLocationZBy(int) {} func TestControllerRelPathFromFunc(t *testing.T) { app := iris.New() @@ -452,6 +453,13 @@ func TestControllerRelPathFromFunc(t *testing.T) { Body().Equal("GET:/42") e.GET("/anything/here").Expect().Status(iris.StatusOK). Body().Equal("GET:/anything/here") + + e.GET("/location/x").Expect().Status(iris.StatusOK). + Body().Equal("GET:/location/x") + e.GET("/location/x/y").Expect().Status(iris.StatusOK). + Body().Equal("GET:/location/x/y") + e.GET("/location/z/42").Expect().Status(iris.StatusOK). + Body().Equal("GET:/location/z/42") } type testControllerActivateListener struct {