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:
@ -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
|
||||
|
Reference in New Issue
Block a user