Merge aba8867fc541410f5c6e1ebdd12c74c680a5d721 into 52fcc5dbf6e94df33ad313858fb94b713e9d1b4a

This commit is contained in:
inaba 2015-12-17 05:36:51 +00:00
commit 4906da1f7c

View File

@ -183,10 +183,10 @@ func (c *Context) MustGet(key string) interface{} {
// Query is a shortcut for c.Request.URL.Query().Get(key) // Query is a shortcut for c.Request.URL.Query().Get(key)
// It is used to return the url query values. // It is used to return the url query values.
// ?id=1234&name=Manu // ?id=1234&name=Manu
// c.Query("id") == "1234" // c.Query("id") == "1234"
// c.Query("name") == "Manu" // c.Query("name") == "Manu"
// c.Query("wtf") == "" // c.Query("wtf") == ""
func (c *Context) Query(key string) (va string) { func (c *Context) Query(key string) (va string) {
va, _ = c.query(key) va, _ = c.query(key)
return return
@ -212,11 +212,9 @@ func (c *Context) DefaultPostForm(key, defaultValue string) string {
// DefaultQuery returns the keyed url query value if it exists, othewise it returns the // DefaultQuery returns the keyed url query value if it exists, othewise it returns the
// specified defaultValue. // specified defaultValue.
// ``` // /?name=Manu
// /?name=Manu // c.DefaultQuery("name", "unknown") == "Manu"
// c.DefaultQuery("name", "unknown") == "Manu" // c.DefaultQuery("id", "none") == "none"
// c.DefaultQuery("id", "none") == "none"
// ```
func (c *Context) DefaultQuery(key, defaultValue string) string { func (c *Context) DefaultQuery(key, defaultValue string) string {
if va, ok := c.query(key); ok { if va, ok := c.query(key); ok {
return va return va
@ -248,9 +246,9 @@ func (c *Context) postForm(key string) (string, bool) {
// Bind checks the Content-Type to select a binding engine automatically, // Bind checks the Content-Type to select a binding engine automatically,
// Depending the "Content-Type" header different bindings are used: // Depending the "Content-Type" header different bindings are used:
// "application/json" --> JSON binding // "application/json" --> JSON binding
// "application/xml" --> XML binding // "application/xml" --> XML binding
// otherwise --> returns an error // otherwise --> returns an error
// If Parses the request's body as JSON if Content-Type == "application/json" using JSON or XML as a JSON input. // If Parses the request's body as JSON if Content-Type == "application/json" using JSON or XML as a JSON input.
// It decodes the json payload into the struct specified as a pointer. // It decodes the json payload into the struct specified as a pointer.
// Like ParseBody() but this method also writes a 400 error if the json is not valid. // Like ParseBody() but this method also writes a 400 error if the json is not valid.