From e34f8479bbc189ece311e0ca20d06dc0fa92e5b3 Mon Sep 17 00:00:00 2001 From: Jianbo Feng Date: Wed, 17 Dec 2014 15:52:48 +0800 Subject: [PATCH] =?UTF-8?q?Add=20all=20type=20support=20for=20UrlFor?= =?UTF-8?q?=E2=80=99s=20params?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- controller.go | 2 +- router.go | 6 +++--- templatefunc.go | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/controller.go b/controller.go index 72ba323b..cc992abc 100644 --- a/controller.go +++ b/controller.go @@ -289,7 +289,7 @@ func (c *Controller) StopRun() { // UrlFor does another controller handler in this request function. // it goes to this controller method if endpoint is not clear. -func (c *Controller) UrlFor(endpoint string, values ...string) string { +func (c *Controller) UrlFor(endpoint string, values ...interface{}) string { if len(endpoint) <= 0 { return "" } diff --git a/router.go b/router.go index 79111226..f12e2e9b 100644 --- a/router.go +++ b/router.go @@ -429,7 +429,7 @@ func (p *ControllerRegistor) insertFilterRouter(pos int, mr *FilterRouter) error // UrlFor does another controller handler in this request function. // it can access any controller method. -func (p *ControllerRegistor) UrlFor(endpoint string, values ...string) string { +func (p *ControllerRegistor) UrlFor(endpoint string, values ...interface{}) string { paths := strings.Split(endpoint, ".") if len(paths) <= 1 { Warn("urlfor endpoint must like path.controller.method") @@ -444,9 +444,9 @@ func (p *ControllerRegistor) UrlFor(endpoint string, values ...string) string { key := "" for k, v := range values { if k%2 == 0 { - key = v + key = fmt.Sprint(v) } else { - params[key] = v + params[key] = fmt.Sprint(v) } } } diff --git a/templatefunc.go b/templatefunc.go index 16067613..cacaae07 100644 --- a/templatefunc.go +++ b/templatefunc.go @@ -246,7 +246,7 @@ func Htmlunquote(src string) string { // /user/John%20Doe // // more detail http://beego.me/docs/mvc/controller/urlbuilding.md -func UrlFor(endpoint string, values ...string) string { +func UrlFor(endpoint string, values ...interface{}) string { return BeeApp.Handlers.UrlFor(endpoint, values...) }