1
0
mirror of https://github.com/labstack/echo.git synced 2024-12-22 20:06:21 +02:00

Add a ParamNames method on Context

This commit is contained in:
Florian Bertholin 2016-02-04 12:37:21 +01:00
parent e512f0430a
commit 9831b9087a
2 changed files with 9 additions and 0 deletions

View File

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

View File

@ -51,6 +51,10 @@ func TestContext(t *testing.T) {
// Socket // Socket
assert.Nil(t, c.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 // Param by id
c.pnames = []string{"id"} c.pnames = []string{"id"}
c.pvalues = []string{"1"} c.pvalues = []string{"1"}