Add QueryParam to Context

This commit is contained in:
Nise Void 2018-11-30 14:27:00 +01:00
parent d30d304cea
commit 4cc4ce2a2e
Signed by: NiseVoid
GPG Key ID: FBA14AC83EA602F3

View File

@ -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{})} 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 { func (c *Context) Redirect(code int, url string) error {
http.Redirect(c.Response, c.Request, url, code) http.Redirect(c.Response, c.Request, url, code)
return nil return nil