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:
parent
e512f0430a
commit
9831b9087a
@ -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
|
||||
|
@ -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"}
|
||||
|
Loading…
Reference in New Issue
Block a user