Add QueryParam to Context
This commit is contained in:
		
							parent
							
								
									d30d304cea
								
							
						
					
					
						commit
						4cc4ce2a2e
					
				
					 1 changed files with 9 additions and 0 deletions
				
			
		|  | @ -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 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue