From a2023cf8f37898f90ff2cff06a3289c862c517c7 Mon Sep 17 00:00:00 2001 From: ssobolewski Date: Sun, 20 Oct 2019 08:01:21 -0600 Subject: [PATCH] Add additional methods --- context.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/context.go b/context.go index e45e977..e7bd0f5 100644 --- a/context.go +++ b/context.go @@ -116,3 +116,12 @@ func (c *Context) Redirect(url string) { func (c *Context) QueryValue(key string) string { return c.r.URL.Query().Get(key) } + +func (c *Context) QueryValueWithDefault(key string, def string) string { + val := c.r.URL.Query().Get(key) + if val == "" { + return def + } + return val +} +