- 
                Notifications
    
You must be signed in to change notification settings  - Fork 8.5k
 
feat: allow custom unmarshalers for form binding: json/text/binary #3335
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
feat: allow custom unmarshalers for form binding: json/text/binary #3335
Conversation
| 
           Lint error.  | 
    
2952371    to
    74734ca      
    Compare
  
    | 
           @slockij Please rebase the master branch.  | 
    
74734ca    to
    c59af23      
    Compare
  
    | 
           @thinkerou help to review.  | 
    
          Codecov Report
 
 @@            Coverage Diff             @@
##           master    #3335      +/-   ##
==========================================
- Coverage   98.63%   98.18%   -0.46%     
==========================================
  Files          42       42              
  Lines        3151     3136      -15     
==========================================
- Hits         3108     3079      -29     
- Misses         29       42      +13     
- Partials       14       15       +1     
 Flags with carried forward coverage won't be shown. Click here to find out more. 
 Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.  | 
    
| 
           guys if I can help here let me know.  | 
    
c59af23    to
    26c932b      
    Compare
  
    | ``` | ||
| 
               | 
          ||
| ```console | ||
| $ curl "localhost:8085/[email protected]" | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How come request query parameters are read into a json unmarshaller? What happens when json is posted in curl body?
| } | ||
| 
               | 
          ||
| type jsonUnmarshaler interface { | ||
| UnmarshalJSON([]byte) error | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason to use multiple different interfaces? Given that these will always execute in a specific order. JSON then TEXT then BINARY. If all 3 are defined only JSON one will be executed. So in this case only 1 interface would be enough to define the unmarshaller override behaviour. E.g. func Unmarshal([]byte) error
| assert.Equal(t, "test", s.Email.Name) | ||
| assert.Equal(t, "example.org", s.Email.Host) | ||
| 
               | 
          ||
| err = mappingByPtr(&s, formSource{"Email": {`not an email`}}, "form") | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally fuzzing would be a separate test. Right now it's not testing 1 unit of code. Also helps with readability.
Uh oh!
There was an error while loading. Please reload this page.