From 9831b9087a47f0af18c142f5d41b54103741dde3 Mon Sep 17 00:00:00 2001 From: Florian Bertholin Date: Thu, 4 Feb 2016 12:37:21 +0100 Subject: [PATCH] Add a ParamNames method on Context --- context.go | 5 +++++ context_test.go | 4 ++++ 2 files changed, 9 insertions(+) diff --git a/context.go b/context.go index b4962373..5cb07e05 100644 --- a/context.go +++ b/context.go @@ -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 diff --git a/context_test.go b/context_test.go index 62b44044..4b9f7ca3 100644 --- a/context_test.go +++ b/context_test.go @@ -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"}