diff --git a/README.md b/README.md index a6903120..7f55d629 100644 --- a/README.md +++ b/README.md @@ -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? - Book cover + Book cover 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. diff --git a/README_ES.md b/README_ES.md index 94aee6b9..aceebc88 100644 --- a/README_ES.md +++ b/README_ES.md @@ -57,7 +57,7 @@ Para obtener una documentación técnica más detallada, puede dirigirse a nuest ### ¿Te gusta leer mientras viajas? - Book cover + Book cover 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. diff --git a/mvc/controller_method_parser.go b/mvc/controller_method_parser.go index 1deb40ef..650a880a 100644 --- a/mvc/controller_method_parser.go +++ b/mvc/controller_method_parser.go @@ -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