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

I don't understand why the bind behavior has been modified #2023

Closed
huangapple opened this issue Nov 10, 2021 · 4 comments
Closed

I don't understand why the bind behavior has been modified #2023

huangapple opened this issue Nov 10, 2021 · 4 comments
Labels

Comments

@huangapple
Copy link

完全搞不懂为啥 c.bind的行为一直变动

之前是 4.1.16, 一不小心升级到4.6.1

给发到线上了, 结果 bind的行为跟旧版本的有所变化, 造成很大的生产事故。

记得之前也变动过一次, 完全搞不懂 这么重要的一个方法, 一直变来变去, 不能加个新方法来解决吗》??

@huangapple
Copy link
Author

This change broke a lot of our APIs developed on 4.1.17.

@huangapple
Copy link
Author

Is there any method in the new version that can work like the previous bind?

@aldas
Copy link
Contributor

aldas commented Nov 11, 2021

You have problems with binding query params not binding with PUT/POST when using c.Bind()? or Bind() not binding to struct?

For PUT/POST you can use

if err := (&DefaultBinder{}).BindQueryParams(c, &payload); err != nil {
  return err
}
if err := c.Bind(u); err != nil {
  return err
}

https://echo.labstack.com/guide/binding/ lists all specific bind methods (query/path/header/body)

For struct tags - add struct tags to your struct definitions.

@aldas aldas added the question label Nov 14, 2021
@aldas aldas closed this as completed Mar 1, 2022
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

2 participants