mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 17:30:56 +00:00
Add all type support for UrlFor’s params
This commit is contained in:
parent
e65d87974a
commit
e34f8479bb
@ -289,7 +289,7 @@ func (c *Controller) StopRun() {
|
|||||||
|
|
||||||
// UrlFor does another controller handler in this request function.
|
// UrlFor does another controller handler in this request function.
|
||||||
// it goes to this controller method if endpoint is not clear.
|
// 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 {
|
if len(endpoint) <= 0 {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
@ -429,7 +429,7 @@ func (p *ControllerRegistor) insertFilterRouter(pos int, mr *FilterRouter) error
|
|||||||
|
|
||||||
// UrlFor does another controller handler in this request function.
|
// UrlFor does another controller handler in this request function.
|
||||||
// it can access any controller method.
|
// 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, ".")
|
paths := strings.Split(endpoint, ".")
|
||||||
if len(paths) <= 1 {
|
if len(paths) <= 1 {
|
||||||
Warn("urlfor endpoint must like path.controller.method")
|
Warn("urlfor endpoint must like path.controller.method")
|
||||||
@ -444,9 +444,9 @@ func (p *ControllerRegistor) UrlFor(endpoint string, values ...string) string {
|
|||||||
key := ""
|
key := ""
|
||||||
for k, v := range values {
|
for k, v := range values {
|
||||||
if k%2 == 0 {
|
if k%2 == 0 {
|
||||||
key = v
|
key = fmt.Sprint(v)
|
||||||
} else {
|
} else {
|
||||||
params[key] = v
|
params[key] = fmt.Sprint(v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -246,7 +246,7 @@ func Htmlunquote(src string) string {
|
|||||||
// /user/John%20Doe
|
// /user/John%20Doe
|
||||||
//
|
//
|
||||||
// more detail http://beego.me/docs/mvc/controller/urlbuilding.md
|
// 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...)
|
return BeeApp.Handlers.UrlFor(endpoint, values...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user