mirror of
https://github.com/kataras/iris.git
synced 2025-02-02 15:30:36 +01:00
godoc: minor
This commit is contained in:
parent
382e7c14cb
commit
43079f75d2
|
@ -43,7 +43,6 @@ func ProxyHandler(target *url.URL, config *tls.Config) *httputil.ReverseProxy {
|
||||||
return p
|
return p
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// mergeQuery return a query string that combines targetQuery and reqQuery
|
// mergeQuery return a query string that combines targetQuery and reqQuery
|
||||||
// and remove the duplicated query parameters of them.
|
// and remove the duplicated query parameters of them.
|
||||||
func mergeQuery(targetQuery, reqQuery string) string {
|
func mergeQuery(targetQuery, reqQuery string) string {
|
||||||
|
|
|
@ -318,7 +318,7 @@ func (c *ControllerActivator) parseMethods() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ControllerActivator) parseMethod(m reflect.Method) {
|
func (c *ControllerActivator) parseMethod(m reflect.Method) {
|
||||||
httpMethod, httpPath, err := parseMethod(c.app.Router.Macros(), m, c.isReservedMethod,c.app.customPathWordFunc)
|
httpMethod, httpPath, err := parseMethod(c.app.Router.Macros(), m, c.isReservedMethod, c.app.customPathWordFunc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if err != errSkip {
|
if err != errSkip {
|
||||||
c.logErrorf("MVC: fail to parse the route path and HTTP method for '%s.%s': %v", c.fullName, m.Name, err)
|
c.logErrorf("MVC: fail to parse the route path and HTTP method for '%s.%s': %v", c.fullName, m.Name, err)
|
||||||
|
|
|
@ -98,7 +98,7 @@ type methodParser struct {
|
||||||
customPathWordFunc CustomPathWordFunc
|
customPathWordFunc CustomPathWordFunc
|
||||||
}
|
}
|
||||||
|
|
||||||
func parseMethod(macros *macro.Macros, fn reflect.Method, skipper func(string) bool,wordFunc CustomPathWordFunc) (method, path string, err error) {
|
func parseMethod(macros *macro.Macros, fn reflect.Method, skipper func(string) bool, wordFunc CustomPathWordFunc) (method, path string, err error) {
|
||||||
if skipper(fn.Name) {
|
if skipper(fn.Name) {
|
||||||
return "", "", errSkip
|
return "", "", errSkip
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,10 @@ var errSkip = errors.New("skip")
|
||||||
|
|
||||||
var allMethods = append(router.AllMethods[0:], []string{"ALL", "ANY"}...)
|
var allMethods = append(router.AllMethods[0:], []string{"ALL", "ANY"}...)
|
||||||
|
|
||||||
type CustomPathWordFunc func(path, w string,wordIndex int) string
|
// CustomPathWordFunc describes the function which can be passed
|
||||||
|
// through `Application.SetCustomPathWordFunc` to customize
|
||||||
|
// the controllers method parsing.
|
||||||
|
type CustomPathWordFunc func(path, w string, wordIndex int) string
|
||||||
|
|
||||||
func addPathWord(path, w string) string {
|
func addPathWord(path, w string) string {
|
||||||
if path[len(path)-1] != '/' {
|
if path[len(path)-1] != '/' {
|
||||||
|
@ -151,7 +154,7 @@ func (p *methodParser) parse() (method, path string, err error) {
|
||||||
return "", "", errSkip
|
return "", "", errSkip
|
||||||
}
|
}
|
||||||
|
|
||||||
wordIndex:=0
|
wordIndex := 0
|
||||||
for {
|
for {
|
||||||
w := p.lexer.next()
|
w := p.lexer.next()
|
||||||
if w == "" {
|
if w == "" {
|
||||||
|
@ -178,9 +181,9 @@ func (p *methodParser) parse() (method, path string, err error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// custom static path.
|
// custom static path.
|
||||||
if p.customPathWordFunc!=nil {
|
if p.customPathWordFunc != nil {
|
||||||
path = p.customPathWordFunc(path, w,wordIndex)
|
path = p.customPathWordFunc(path, w, wordIndex)
|
||||||
}else{
|
} else {
|
||||||
// default static path.
|
// default static path.
|
||||||
path = addPathWord(path, w)
|
path = addPathWord(path, w)
|
||||||
}
|
}
|
||||||
|
|
|
@ -122,6 +122,8 @@ func (app *Application) SetName(appName string) *Application {
|
||||||
return app
|
return app
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SetCustomPathWordFunc sets a custom function
|
||||||
|
// which is responsible to override the existing controllers method parsing.
|
||||||
func (app *Application) SetCustomPathWordFunc(wordFunc CustomPathWordFunc) *Application {
|
func (app *Application) SetCustomPathWordFunc(wordFunc CustomPathWordFunc) *Application {
|
||||||
app.customPathWordFunc = wordFunc
|
app.customPathWordFunc = wordFunc
|
||||||
return app
|
return app
|
||||||
|
|
Loading…
Reference in New Issue
Block a user