bind.go: add BindHeaders() to Bind()
Headers are supported in Bind() and we can find the following in the documentation[1]:
Echo provides the following methods to bind data from different
sources to Go Structs using the Context#Bind(i interface{}) method:
- URL Path parameter
- URL Query parameter
- Request body
- Header
- https://echo.labstack.com/guide/binding/#bind-using-struct-tags
There was a reason why header binding was not added to Bind method. See https://github.com/labstack/echo/pull/1866#issue-877401536
There was a reason why header binding was not added to
Bindmethod. See #1866 (comment)
Hmm, so should we revise the documentation to keep it the same with the implementation ?
There was a reason why header binding was not added to
Bindmethod. See #1866 (comment)Hmm, so should we revise the documentation to keep it the same with the implementation ?
@chiyutianyi The section you are referring to is an introduction to the topic, which is then detailed later. But improving the docs is of course great! You can add a PR for the docs in the https://github.com/labstack/echox project
@lammel @chiyutianyi -- Can we change this PR to expose BindHeaders() on echo.Context such that I can do:
c.BindHeaders(params)
instead of:
(&echo.DefaultBinder{}).BindHeaders(*c, params)
Thanks!
@derekm we can not change context interface by adding new public method as it would be API breaking change.
@aldas -- Ahh, right. No default implementations in Go? At least generics are improving! ;) I do hide the ugly code under some reasonable abstractions. Thanks!
we are using semantic versioning and adding new method to interface would be breaking (backwards incompatible) change and would require bumping major version of library to v5. We do not want to do that - not yet.