Skip to content

context#Bind show different behavior in different cases #1373

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

Closed
3 tasks done
narrowizard opened this issue Jul 26, 2019 · 2 comments
Closed
3 tasks done

context#Bind show different behavior in different cases #1373

narrowizard opened this issue Jul 26, 2019 · 2 comments
Labels

Comments

@narrowizard
Copy link

narrowizard commented Jul 26, 2019

Issue Description

I find that when calling ctx.Bind multi times, different params show different behaviors.
Cases:

  1. PathParams can be bind multi times.
  2. QueryParams can be bind multi times.
  3. FormParams can be bind multi times. (Content-Type == "application/x-www-form-urlencoded" || Content-Type == "application/form-data")
  4. JsonParams can only be bind once.(Content-Type == "application/json")
  5. XmlParams can only be bind once.(Content-Type == "application/xml")

Reason

As metioned in related issues, request body as io.Reader will be consumed after reading.

Thinking(Important)

I think it's something about definition of Content#Bind method. It(Bind method) did two different things in above cases.

  • In case 1,2,3, Bind method Bind params from context.pnames, content.pvalues, request.URL.Query(), request.Form which are idempotent in multiple calling.
  • In case 4,5, Bind method read data from request body, and unmarshal to target interface{}.
    Will it be possible to do a data temp saving in content(like path params) in case 4,5, or restore data to request.Body after binding.

Checklist

  • Dependencies installed
  • No typos
  • Searched existing issues and docs

Related Issues

#976, #782

@narrowizard
Copy link
Author

@vishr

@stale
Copy link

stale bot commented Sep 24, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Sep 24, 2019
@stale stale bot closed this as completed Oct 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant