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

ShouldBindBodyWith() will more types be supported in the future? #3823

Closed
xiaolibuzai-ovo opened this issue Jan 15, 2024 · 2 comments · Fixed by #3871
Closed

ShouldBindBodyWith() will more types be supported in the future? #3823

xiaolibuzai-ovo opened this issue Jan 15, 2024 · 2 comments · Fixed by #3871

Comments

@xiaolibuzai-ovo
Copy link

  • With issues:
    • Use the search tool before opening a new issue.
    • Please provide source code and commit sha if you found a bug.
    • Review existing issues and provide feedback or react to them.

Description

If I want to perform binding operations on the request body multiple times, I think I should use ShouldBindBodyWith (), but each operation needs to specify the type, such as binding.JSON, so I think can we provide separate APIs for each type? For example, ShouldBindBodyWithJson() to operate on data of type binding.JSON, which can be used more conveniently in upper-level development

How to reproduce

Expectations

$ curl http://localhost:9000/hello/world
Hello world

Actual result

$ curl -i http://localhost:9000/hello/world
<YOUR RESULT>

Environment

  • go version: latest
  • gin version (or commit ref):
  • operating system:
@RedCrazyGhost
Copy link
Contributor

Please describe the benefits that this proposal can bring in order to have a full understanding of the need for its development.

You can use the ShouldBindXXX(obj any) method to process the data in the request body

@RedCrazyGhost
Copy link
Contributor

Regarding your proposal, I thought about it for a while, and if other types of approaches were provided, it could really improve the development experience.

I'm currently experiencing some problems where parsing JSON content is something that doesn't meet my expectations, and I can only wait for someone else's answer.(See Issue)

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 a pull request may close this issue.

2 participants