Remove incorrect comments about context.Bind() and improve docs (#3028)
This commit is contained in:
		
							
								
								
									
										12
									
								
								context.go
									
									
									
									
									
								
							
							
						
						
									
										12
									
								
								context.go
									
									
									
									
									
								
							@ -601,11 +601,10 @@ func (c *Context) SaveUploadedFile(file *multipart.FileHeader, dst string) error
 | 
				
			|||||||
	return err
 | 
						return err
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Bind checks the Content-Type to select a binding engine automatically,
 | 
					// Bind checks the Method and Content-Type to select a binding engine automatically,
 | 
				
			||||||
// Depending on the "Content-Type" header different bindings are used:
 | 
					// Depending on the "Content-Type" header different bindings are used, for example:
 | 
				
			||||||
//     "application/json" --> JSON binding
 | 
					//     "application/json" --> JSON binding
 | 
				
			||||||
//     "application/xml"  --> XML binding
 | 
					//     "application/xml"  --> XML binding
 | 
				
			||||||
// otherwise --> returns an error.
 | 
					 | 
				
			||||||
// It parses the request's body as JSON if Content-Type == "application/json" using JSON or XML as a JSON input.
 | 
					// It 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.
 | 
				
			||||||
// It writes a 400 error and sets Content-Type header "text/plain" in the response if input is not valid.
 | 
					// It writes a 400 error and sets Content-Type header "text/plain" in the response if input is not valid.
 | 
				
			||||||
@ -660,14 +659,13 @@ func (c *Context) MustBindWith(obj interface{}, b binding.Binding) error {
 | 
				
			|||||||
	return nil
 | 
						return nil
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// ShouldBind checks the Content-Type to select a binding engine automatically,
 | 
					// ShouldBind checks the Method and Content-Type to select a binding engine automatically,
 | 
				
			||||||
// Depending on the "Content-Type" header different bindings are used:
 | 
					// Depending on the "Content-Type" header different bindings are used, for example:
 | 
				
			||||||
//     "application/json" --> JSON binding
 | 
					//     "application/json" --> JSON binding
 | 
				
			||||||
//     "application/xml"  --> XML binding
 | 
					//     "application/xml"  --> XML binding
 | 
				
			||||||
// otherwise --> returns an error
 | 
					 | 
				
			||||||
// It parses the request's body as JSON if Content-Type == "application/json" using JSON or XML as a JSON input.
 | 
					// It 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 c.Bind() but this method does not set the response status code to 400 and abort if the json is not valid.
 | 
					// Like c.Bind() but this method does not set the response status code to 400 or abort if input is not valid.
 | 
				
			||||||
func (c *Context) ShouldBind(obj interface{}) error {
 | 
					func (c *Context) ShouldBind(obj interface{}) error {
 | 
				
			||||||
	b := binding.Default(c.Request.Method, c.ContentType())
 | 
						b := binding.Default(c.Request.Method, c.ContentType())
 | 
				
			||||||
	return c.ShouldBindWith(obj, b)
 | 
						return c.ShouldBindWith(obj, b)
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user