mirror of
https://github.com/labstack/echo.git
synced 2025-06-08 23:56:20 +02:00
Fixed #1052, dropped param alias feature
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
parent
67a5dcdb91
commit
ec048ea523
@ -274,13 +274,6 @@ func (c *context) Param(name string) string {
|
|||||||
if n == name {
|
if n == name {
|
||||||
return c.pvalues[i]
|
return c.pvalues[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Param name with aliases
|
|
||||||
for _, p := range strings.Split(n, ",") {
|
|
||||||
if p == name {
|
|
||||||
return c.pvalues[i]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ""
|
return ""
|
||||||
|
@ -303,18 +303,6 @@ func TestContextPathParam(t *testing.T) {
|
|||||||
assert.Equal(t, "501", c.Param("fid"))
|
assert.Equal(t, "501", c.Param("fid"))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestContextPathParamNamesAlais(t *testing.T) {
|
|
||||||
e := New()
|
|
||||||
req := httptest.NewRequest(GET, "/", nil)
|
|
||||||
c := e.NewContext(req, nil)
|
|
||||||
|
|
||||||
c.SetParamNames("id,name")
|
|
||||||
c.SetParamValues("joe")
|
|
||||||
|
|
||||||
assert.Equal(t, "joe", c.Param("id"))
|
|
||||||
assert.Equal(t, "joe", c.Param("name"))
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestContextFormValue(t *testing.T) {
|
func TestContextFormValue(t *testing.T) {
|
||||||
f := make(url.Values)
|
f := make(url.Values)
|
||||||
f.Set("name", "Jon Snow")
|
f.Set("name", "Jon Snow")
|
||||||
|
@ -15,7 +15,7 @@ type (
|
|||||||
|
|
||||||
// Rules defines the URL path rewrite rules. The values captured in asterisk can be
|
// Rules defines the URL path rewrite rules. The values captured in asterisk can be
|
||||||
// retrieved by index e.g. $1, $2 and so on.
|
// retrieved by index e.g. $1, $2 and so on.
|
||||||
// Examples:
|
// Example:
|
||||||
// "/old": "/new",
|
// "/old": "/new",
|
||||||
// "/api/*": "/$1",
|
// "/api/*": "/$1",
|
||||||
// "/js/*": "/public/javascripts/$1",
|
// "/js/*": "/public/javascripts/$1",
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package echo
|
package echo
|
||||||
|
|
||||||
import "strings"
|
|
||||||
|
|
||||||
type (
|
type (
|
||||||
// Router is the registry of all registered routes for an `Echo` instance for
|
// Router is the registry of all registered routes for an `Echo` instance for
|
||||||
// request matching and URL path parameter parsing.
|
// request matching and URL path parameter parsing.
|
||||||
@ -175,12 +173,6 @@ func (r *Router) insert(method, path string, h HandlerFunc, t kind, ppath string
|
|||||||
if len(cn.pnames) == 0 { // Issue #729
|
if len(cn.pnames) == 0 { // Issue #729
|
||||||
cn.pnames = pnames
|
cn.pnames = pnames
|
||||||
}
|
}
|
||||||
for i, n := range pnames {
|
|
||||||
// Param name aliases
|
|
||||||
if i < len(cn.pnames) && !strings.Contains(cn.pnames[i], n) {
|
|
||||||
cn.pnames[i] += "," + n
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
Loading…
x
Reference in New Issue
Block a user