e34f8479 by Jianbo Feng

Add all type support for UrlFor’s params

1 parent e65d8797
...@@ -289,7 +289,7 @@ func (c *Controller) StopRun() { ...@@ -289,7 +289,7 @@ func (c *Controller) StopRun() {
289 289
290 // UrlFor does another controller handler in this request function. 290 // UrlFor does another controller handler in this request function.
291 // it goes to this controller method if endpoint is not clear. 291 // it goes to this controller method if endpoint is not clear.
292 func (c *Controller) UrlFor(endpoint string, values ...string) string { 292 func (c *Controller) UrlFor(endpoint string, values ...interface{}) string {
293 if len(endpoint) <= 0 { 293 if len(endpoint) <= 0 {
294 return "" 294 return ""
295 } 295 }
......
...@@ -429,7 +429,7 @@ func (p *ControllerRegistor) insertFilterRouter(pos int, mr *FilterRouter) error ...@@ -429,7 +429,7 @@ func (p *ControllerRegistor) insertFilterRouter(pos int, mr *FilterRouter) error
429 429
430 // UrlFor does another controller handler in this request function. 430 // UrlFor does another controller handler in this request function.
431 // it can access any controller method. 431 // it can access any controller method.
432 func (p *ControllerRegistor) UrlFor(endpoint string, values ...string) string { 432 func (p *ControllerRegistor) UrlFor(endpoint string, values ...interface{}) string {
433 paths := strings.Split(endpoint, ".") 433 paths := strings.Split(endpoint, ".")
434 if len(paths) <= 1 { 434 if len(paths) <= 1 {
435 Warn("urlfor endpoint must like path.controller.method") 435 Warn("urlfor endpoint must like path.controller.method")
...@@ -444,9 +444,9 @@ func (p *ControllerRegistor) UrlFor(endpoint string, values ...string) string { ...@@ -444,9 +444,9 @@ func (p *ControllerRegistor) UrlFor(endpoint string, values ...string) string {
444 key := "" 444 key := ""
445 for k, v := range values { 445 for k, v := range values {
446 if k%2 == 0 { 446 if k%2 == 0 {
447 key = v 447 key = fmt.Sprint(v)
448 } else { 448 } else {
449 params[key] = v 449 params[key] = fmt.Sprint(v)
450 } 450 }
451 } 451 }
452 } 452 }
......
...@@ -246,7 +246,7 @@ func Htmlunquote(src string) string { ...@@ -246,7 +246,7 @@ func Htmlunquote(src string) string {
246 // /user/John%20Doe 246 // /user/John%20Doe
247 // 247 //
248 // more detail http://beego.me/docs/mvc/controller/urlbuilding.md 248 // more detail http://beego.me/docs/mvc/controller/urlbuilding.md
249 func UrlFor(endpoint string, values ...string) string { 249 func UrlFor(endpoint string, values ...interface{}) string {
250 return BeeApp.Handlers.UrlFor(endpoint, values...) 250 return BeeApp.Handlers.UrlFor(endpoint, values...)
251 } 251 }
252 252
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!