-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Closed
Description
Issue Description
It is common for POST/UPDATE requests to have the resource identified sent on the URL while the content is sent on the body. It'd be useful to have the DefaultBinder to bind route parameters into the Model. Example below.
Checklist
- Dependencies installed
- No typos
- Searched existing issues and docs
Expected behaviour
type newCommentInput struct {
Number int `param:"number"`
Content string `json:"content"`
}
input := new(newCommentInput)
c.Bind(input);
This would bind both Number and Content.
Actual behaviour
It is necessary to use both c.Bind
and c.Param('number')
to fill this model.
Steps to reproduce
n/a
Working code to debug
An example of how I'm currently doing it https://github.com/getfider/fider/blob/557d3c515b8b5ac55ae1c0f7161d2d11b448fef7/app/handlers/idea.go#L131-L152
Just as information, this is common in other frameworks. Following example from C#.
[HttpPut("{id}")]
public IActionResult Update([FromRoute] string id, [FromBody] TodoItem item);
Version/commit
v3.2.1
Thanks for creating Echo :)
If approved, I could give it a try and work on it.
marcuxyz
Metadata
Metadata
Assignees
Labels
No labels