1
0
mirror of https://github.com/labstack/echo.git synced 2025-02-03 13:11:39 +02:00

Merge pull request #355 from heetch/feature/add-param-names

Add a ParamNames method on Context
This commit is contained in:
Vishal Rana 2016-02-05 08:28:10 -08:00
commit 9f3aaa8f0b
2 changed files with 9 additions and 0 deletions

View File

@ -58,6 +58,11 @@ func (c *Context) Socket() *websocket.Conn {
return c.socket
}
// ParamNames returns path parameter names.
func (c *Context) ParamNames() []string {
return c.pnames
}
// Path returns the registered path for the handler.
func (c *Context) Path() string {
return c.path

View File

@ -51,6 +51,10 @@ func TestContext(t *testing.T) {
// Socket
assert.Nil(t, c.Socket())
// ParamNames
c.pnames = []string{"user_id", "id"}
assert.EqualValues(t, []string{"user_id", "id"}, c.ParamNames())
// Param by id
c.pnames = []string{"id"}
c.pvalues = []string{"1"}