Skip to content
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

fix bind with map[string]interface{} for json post but with no params #989

Closed
wants to merge 1 commit into from

Conversation

wonderflow
Copy link

@wonderflow wonderflow commented Aug 11, 2017

hello, I hope to handle a post request with no params, but the binddata failed me.

bind data will check type as struct, I hope to decode use map[string]interface{}

hope to be merged.

@codecov
Copy link

codecov bot commented Aug 11, 2017

Codecov Report

Merging #989 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #989   +/-   ##
=======================================
  Coverage   76.56%   76.56%           
=======================================
  Files          27       27           
  Lines        2232     2232           
=======================================
  Hits         1709     1709           
  Misses        400      400           
  Partials      123      123
Impacted Files Coverage Δ
bind.go 80.39% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 1e9845a...1e6420a. Read the comment docs.

@vishr
Copy link
Member

vishr commented Aug 14, 2017

@goenning can you review this change?

@goenning
Copy link
Contributor

@vishr LGTM, > 0 is the right condition.

@vishr
Copy link
Member

vishr commented Aug 14, 2017

@goenning A request similar request with params will fail. This change has introduced new bugs recently, do you think this can be handled in a custom binder?

@goenning
Copy link
Contributor

@vishr Are you referring to #988? If so, this PR will fix that. Did you notice any other regression?

I'd love to keep this on DefaultBinder as binding from route parameter is not an application-specific feature.

@vishr
Copy link
Member

vishr commented Aug 14, 2017

@goenning I understand this PR will fix it, however, I could see a request with params binding to a map will fail. e.g.

Path: /users/:id
Payload:

{
  "name": "John Snow"
}

@vishr vishr closed this Aug 14, 2017
@vishr vishr reopened this Aug 14, 2017
@goenning
Copy link
Contributor

@vishr I see there's a new check reflect.TypeOf(ptr).Elem().Kind() == reflect.Slice on bindPathData. Changing it to typ.Kind() != reflect.Struct would fix it.

I get your point, there could be more unforeseen binding issues. But still, I'd vote for keeping it. I've upgrade to the latest commit and had no issues because all my scenarios are binding to a struct, not slices/maps. But such cases are now covered by unit tests.

@vishr
Copy link
Member

vishr commented Aug 14, 2017

@goenning Multiple bugs started popping just after this change and if I am not wrong this change was done for #980.

@wonderflow
Copy link
Author

@vishr @goenning so what will be done to this issue?

@vishr
Copy link
Member

vishr commented Aug 15, 2017

@wonderflow I have reverted this change, things should work fine now.

@wonderflow
Copy link
Author

yes, I have tested, it's ok now, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants