Skip to content

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

Description

@huangapple

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

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

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

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

Activity

  1. huangapple commented on Nov 11, 2021

    @huangapple
    Author

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

  2. huangapple commented on Nov 11, 2021

    @huangapple
    Author

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

  3. aldas commented on Nov 11, 2021

    @aldas
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions