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

@ -55,7 +55,7 @@ For a more detailed technical documentation you can head over to our [godocs](ht
### Do you like to read while traveling?
<a href="https://bit.ly/iris-req-book"> <img alt="Book cover" src="https://iris-go.com/images/iris-book-cover.jpg" width="200" /> </a>
<a href="https://bit.ly/iris-req-book"> <img alt="Book cover" src="https://iris-go.com/images/iris-book-cover-sm.jpg" width="200" /> </a>
You can [request](https://bit.ly/iris-req-book) a PDF version and online access of the **E-Book** today and be participated in the development of Iris.

View File

@ -57,7 +57,7 @@ Para obtener una documentación técnica más detallada, puede dirigirse a nuest
### ¿Te gusta leer mientras viajas?
<a href="https://bit.ly/iris-req-book"> <img alt="Book cover" src="https://iris-go.com/images/iris-book-cover.jpg" width="200" /> </a>
<a href="https://bit.ly/iris-req-book"> <img alt="Book cover" src="https://iris-go.com/images/iris-book-cover-sm.jpg" width="200" /> </a>
Puedes [solicitar](https://bit.ly/iris-req-book) una versión en PDF y acceso en línea del **E-Book** hoy y participar en el desarrollo de Iris.

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