refactor(form_mapping.go): mapping ptr, struct and map (#1749)
* refactor(form_mapping.go): mapping ptr, struct and map * fix #1672 correct work with ptr - not create value if field is not set * avoid allocations on strings.Split() - change to strings.Index() * fix #610 tag value "-" is mean ignoring field * struct fields mapped like json.Unmarshal * map fields mapped like json.Unmarshal * fix after @thinkerou review
This commit is contained in:
		
							
								
								
									
										18
									
								
								README.md
									
									
									
									
									
								
							
							
						
						
									
										18
									
								
								README.md
									
									
									
									
									
								
							@ -1836,24 +1836,6 @@ $ curl "http://localhost:8080/getd?field_x=hello&field_d=world"
 | 
			
		||||
{"d":"world","x":{"FieldX":"hello"}}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
**NOTE**: NOT support the follow style struct:
 | 
			
		||||
 | 
			
		||||
```go
 | 
			
		||||
type StructX struct {
 | 
			
		||||
    X struct {} `form:"name_x"` // HERE have form
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type StructY struct {
 | 
			
		||||
    Y StructX `form:"name_y"` // HERE have form
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
type StructZ struct {
 | 
			
		||||
    Z *StructZ `form:"name_z"` // HERE have form
 | 
			
		||||
}
 | 
			
		||||
```
 | 
			
		||||
 | 
			
		||||
In a word, only support nested custom struct which have no `form` now.
 | 
			
		||||
 | 
			
		||||
### Try to bind body into different structs
 | 
			
		||||
 | 
			
		||||
The normal methods for binding request body consumes `c.Request.Body` and they
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user