Add Header bind methods to README (#2025)
This commit is contained in:
		@ -622,10 +622,10 @@ Note that you need to set the corresponding binding tag on all fields you want t
 | 
			
		||||
 | 
			
		||||
Also, Gin provides two sets of methods for binding:
 | 
			
		||||
- **Type** - Must bind
 | 
			
		||||
  - **Methods** - `Bind`, `BindJSON`, `BindXML`, `BindQuery`, `BindYAML`
 | 
			
		||||
  - **Methods** - `Bind`, `BindJSON`, `BindXML`, `BindQuery`, `BindYAML`, `BindHeader`
 | 
			
		||||
  - **Behavior** - These methods use `MustBindWith` under the hood. If there is a binding error, the request is aborted with `c.AbortWithError(400, err).SetType(ErrorTypeBind)`. This sets the response status code to 400 and the `Content-Type` header is set to `text/plain; charset=utf-8`. Note that if you try to set the response code after this, it will result in a warning `[GIN-debug] [WARNING] Headers were already written. Wanted to override status code 400 with 422`. If you wish to have greater control over the behavior, consider using the `ShouldBind` equivalent method.
 | 
			
		||||
- **Type** - Should bind
 | 
			
		||||
  - **Methods** - `ShouldBind`, `ShouldBindJSON`, `ShouldBindXML`, `ShouldBindQuery`, `ShouldBindYAML`
 | 
			
		||||
  - **Methods** - `ShouldBind`, `ShouldBindJSON`, `ShouldBindXML`, `ShouldBindQuery`, `ShouldBindYAML`, `ShouldBindHeader`
 | 
			
		||||
  - **Behavior** - These methods use `ShouldBindWith` under the hood. If there is a binding error, the error is returned and it is the developer's responsibility to handle the request and error appropriately.
 | 
			
		||||
 | 
			
		||||
When using the Bind-method, Gin tries to infer the binder depending on the Content-Type header. If you are sure what you are binding, you can use `MustBindWith` or `ShouldBindWith`.
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user