- 
                Notifications
    
You must be signed in to change notification settings  - Fork 8.5k
 
export ErrUnknownType and code adjust for broken pipe and json invalid and use http.MethodGet instead of raw GET string and IsWebsocket check #2785
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?
Conversation
          Codecov Report
 
 @@            Coverage Diff             @@
##           master    #2785      +/-   ##
==========================================
- Coverage   98.77%   98.71%   -0.07%     
==========================================
  Files          41       41              
  Lines        3106     2094    -1012     
==========================================
- Hits         3068     2067    -1001     
+ Misses         26       15      -11     
  Partials       12       12              
 Flags with carried forward coverage won't be shown. Click here to find out more. 
 Continue to review full report at Codecov. 
  | 
    
        
          
                binding/json.go
              
                Outdated
          
        
      | EnableDecoderDisallowUnknownFields = false | ||
| 
               | 
          ||
| // JsonReqInvalid json invalid when request is nil or request body is nil. | ||
| JsonReqInvalid = errors.New("invalid request") | 
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.
Maybe InvaildRequest?
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.
OK, I've adjusted it.
| 
           The name you said is OK, but the JSON request request is illegal. I'll adjust it appropriately. 
…------------------ Original ------------------
From: Bo-Yi Wu ***@***.***>
Date: Tue,Jul 13,2021 9:46 AM
To: gin-gonic/gin ***@***.***>
Cc: heige ***@***.***>, Author ***@***.***>
Subject: Re: [gin-gonic/gin] export ErrUnknownType and code adjust for broken pipe and json invalid and use http.MethodGet instead of raw GET string and IsWebsocket check (#2785)
@appleboy commented on this pull request.
In binding/json.go:
 > -// keys which do not match any non-ignored, exported fields in the destination. -var EnableDecoderDisallowUnknownFields = false +var ( +// EnableDecoderUseNumber is used to call the UseNumber method on the JSON +// Decoder instance. UseNumber causes the Decoder to unmarshal a number into an +// interface{} as a Number instead of as a float64. +EnableDecoderUseNumber = false + +// EnableDecoderDisallowUnknownFields is used to call the DisallowUnknownFields method +// on the JSON Decoder instance. DisallowUnknownFields causes the Decoder to +// return an error when the destination is a struct and the input contains object +// keys which do not match any non-ignored, exported fields in the destination. +EnableDecoderDisallowUnknownFields = false + +// JsonReqInvalid json invalid when request is nil or request body is nil. +JsonReqInvalid = errors.New("invalid request")
Maybe InvaildRequest?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe. 
 | 
    
| } | ||
| 
               | 
          ||
| // IsBroken Check error for a broken connection | ||
| func IsBroken(err interface{}) bool { | 
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.
public method?
| 
           yes,I see that other components of gin are in use. Here, it is declared as an open method to facilitate reuse. 
…------------------ Original ------------------
From: thinkerou ***@***.***>
Date: Thu,Jul 22,2021 8:00 AM
To: gin-gonic/gin ***@***.***>
Cc: heige ***@***.***>, Author ***@***.***>
Subject: Re: [gin-gonic/gin] export ErrUnknownType and code adjust for broken pipe and json invalid and use http.MethodGet instead of raw GET string and IsWebsocket check (#2785)
@thinkerou commented on this pull request.
In recovery.go:
 > @@ -47,6 +47,20 @@ func RecoveryWithWriter(out io.Writer, recovery ...RecoveryFunc) HandlerFunc {  return CustomRecoveryWithWriter(out, defaultHandleRecovery)  }   +// IsBroken Check error for a broken connection +func IsBroken(err interface{}) bool {
public method?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe. 
 | 
    
        
          
                binding/json.go
              
                Outdated
          
        
      | func (jsonBinding) Bind(req *http.Request, obj interface{}) error { | ||
| if req == nil || req.Body == nil { | ||
| return errors.New("invalid request") | ||
| return InvalidRequest | 
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 about:
| return InvalidRequest | |
| return ErrInvalidRequest | 
I think it's a common way to name errors.
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.
ok,thinks @kszafran
| 
           @daheige Please help to resolve conflicts.  | 
    
| 
           i have adjusted it ok, thinks.
 原始邮件
发件人: Bo-Yi ***@***.***>
收件人: ***@***.***>
抄送: ***@***.***>; ***@***.***>
发送时间: 2022年4月16日(周六) 09:54
主题: Re: [gin-gonic/gin] export ErrUnknownType and code adjust for brokenpipe and json invalid and use http.MethodGet instead of raw GET string andIsWebsocket check (#2785)
@daheige Please help to resolve conflicts.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.Message ID: ***@***.***> 
       | 
    
1.export ErrUnknownType unknown request type
2.code adjust for broken pipe and json invalid and use http.MethodGet instead of raw GET string
3.IsWebsocket check