From 4cc4ce2a2e6b201a922cf952e75cc06f423ea857 Mon Sep 17 00:00:00 2001 From: NiseVoid Date: Fri, 30 Nov 2018 14:27:00 +0100 Subject: [PATCH] Add QueryParam to Context --- context.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/context.go b/context.go index 21b1307..2c65adb 100644 --- a/context.go +++ b/context.go @@ -20,6 +20,15 @@ func newContext(router *Router, res http.ResponseWriter, req *http.Request, para return &Context{router, req, res, param.ByName, make(map[string]interface{})} } +func (c *Context) QueryParam(param string) string { + params := c.Request.URL.Query()[param] + if params == nil { + return `` + } + + return params[0] +} + func (c *Context) Redirect(code int, url string) error { http.Redirect(c.Response, c.Request, url, code) return nil