From 1e04986e53e36c11a6823c44f5d89d96e088619b Mon Sep 17 00:00:00 2001 From: Vishal Rana Date: Sun, 17 Apr 2016 09:41:20 -0700 Subject: [PATCH] Var args for Context#SetParamNames and Context#SetParamValues. Signed-off-by: Vishal Rana --- context.go | 8 ++++---- router.go | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/context.go b/context.go index a925c896..2591e1e5 100644 --- a/context.go +++ b/context.go @@ -53,13 +53,13 @@ type ( ParamNames() []string // SetParamNames sets path parameter names. - SetParamNames([]string) + SetParamNames(...string) // ParamValues returns path parameter values. ParamValues() []string // SetParamValues sets path parameter values. - SetParamValues([]string) + SetParamValues(...string) // QueryParam returns the query param for the provided name. It is an alias // for `engine.URL#QueryParam()`. @@ -241,7 +241,7 @@ func (c *context) ParamNames() []string { return c.pnames } -func (c *context) SetParamNames(names []string) { +func (c *context) SetParamNames(names ...string) { c.pnames = names } @@ -249,7 +249,7 @@ func (c *context) ParamValues() []string { return c.pvalues } -func (c *context) SetParamValues(values []string) { +func (c *context) SetParamValues(values ...string) { c.pvalues = values } diff --git a/router.go b/router.go index d7d7df4a..ffcc04ae 100644 --- a/router.go +++ b/router.go @@ -400,7 +400,7 @@ func (r *Router) Find(method, path string, context Context) { End: context.SetHandler(cn.findHandler(method)) context.SetPath(cn.ppath) - context.SetParamNames(cn.pnames) + context.SetParamNames(cn.pnames...) // NOTE: Slow zone... if context.Handler() == nil { @@ -417,7 +417,7 @@ End: context.SetHandler(cn.checkMethodNotAllowed()) } context.SetPath(cn.ppath) - context.SetParamNames(cn.pnames) + context.SetParamNames(cn.pnames...) pvalues[len(cn.pnames)-1] = "" }