1
0
mirror of https://github.com/kataras/iris.git synced 2025-12-18 10:27:06 +00:00
Former-commit-id: 3aeb222d0cc273553c5b97905425e9f81956fa27
This commit is contained in:
Gerasimos (Makis) Maropoulos
2019-09-01 23:49:09 +03:00
parent a3a18f3f9b
commit c0136f0d84
3 changed files with 16 additions and 5 deletions

View File

@@ -128,6 +128,14 @@ var errSkip = errors.New("skip")
var allMethods = append(router.AllMethods[0:], []string{"ALL", "ANY"}...)
func addPathWord(path, w string) string {
if path[len(path)-1] != '/' {
path += "/"
}
path += strings.ToLower(w)
return path
}
func (p *methodParser) parse() (method, path string, err error) {
funcArgPos := 0
path = "/"
@@ -173,7 +181,7 @@ func (p *methodParser) parse() (method, path string, err error) {
continue
}
// static path.
path += "/" + strings.ToLower(w)
path = addPathWord(path, w)
}
return
}
@@ -184,7 +192,7 @@ func (p *methodParser) parsePathParam(path string, w string, funcArgPos int) (st
if typ.NumIn() <= funcArgPos {
// By found but input arguments are not there, so act like /by path without restricts.
path += "/" + strings.ToLower(w)
path = addPathWord(path, w)
return path, funcArgPos, nil
}
@@ -228,7 +236,10 @@ func (p *methodParser) parsePathParam(path string, w string, funcArgPos int) (st
}
// /{argfirst:path}, /{argfirst:long}...
path += fmt.Sprintf("/{%s:%s}", paramKey, m.Indent())
if path[len(path)-1] != '/' {
path += "/"
}
path += fmt.Sprintf("{%s:%s}", paramKey, m.Indent())
if nextWord == "" && typ.NumIn() > funcArgPos+1 {
// By is the latest word but func is expected