1
0
mirror of https://github.com/astaxie/beego.git synced 2025-07-12 00:01:02 +00:00

add util func to get the url fix #282

UrlFor(endpoint string, values ...string) string
This commit is contained in:
astaxie
2013-11-10 23:05:07 +08:00
parent 167ad203cb
commit 9446563e5b
6 changed files with 157 additions and 2 deletions

View File

@ -16,6 +16,7 @@ import (
"net/http"
"net/url"
"os"
"reflect"
"strconv"
"strings"
"time"
@ -175,6 +176,17 @@ func (c *Controller) Abort(code string) {
panic(code)
}
func (c *Controller) UrlFor(endpoint string, values ...string) string {
if len(endpoint) <= 0 {
return ""
}
if endpoint[0] == '.' {
return UrlFor(reflect.Indirect(reflect.ValueOf(c.AppController)).Type().Name()+endpoint, values...)
} else {
return UrlFor(endpoint, values...)
}
}
func (c *Controller) ServeJson(encoding ...bool) {
var hasIndent bool
var hasencoding bool