1
0
mirror of https://github.com/kataras/iris.git synced 2026-03-06 16:35:57 +00:00
Former-commit-id: 0359fbf7dd3ff151db7b0575510e611bed683d0e
This commit is contained in:
Gerasimos (Makis) Maropoulos
2017-02-22 16:38:55 +02:00
parent 42cf24fda2
commit 4de98254fd
5 changed files with 33 additions and 9 deletions

View File

@@ -62,8 +62,16 @@ func New() iris.Policies {
RouterReversionPolicy: iris.RouterReversionPolicy{
// path normalization done on iris' side
StaticPath: staticPath,
WildcardPath: func(requestPath string, paramName string) string {
return requestPath + "/{" + paramName + ":.*}"
WildcardPath: func(path string, paramName string) string {
// {param:.*}
wildcardPart := "{" + paramName + ":.*}"
if path[len(path)-1] != '/' {
// if not ending with slash then prepend the slash to the wildcard path part
wildcardPart = "/" + wildcardPart
}
// finally return the path given + the wildcard path part
return path + wildcardPart
},
// Note: on gorilla mux the {{ url }} and {{ path}} should give the key and the value, not only the values by order.
// {{ url "nameOfTheRoute" "parameterName" "parameterValue"}}.

View File

@@ -536,7 +536,15 @@ func New() iris.Policies {
return path
},
WildcardPath: func(path string, paramName string) string {
return path + slash + matchEverythingString + paramName
// *param
wildcardPart := matchEverythingString + paramName
if path[len(path)-1] != slashByte {
// if not ending with slash then prepend the slash to the wildcard path part
wildcardPart = slash + wildcardPart
}
// finally return the path given + the wildcard path part
return path + wildcardPart
},
// path = "/api/users/:id", args = ["42"]
// return "/api/users/42"