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

Request: New bind property for route parameters #972

Closed
3 tasks done
goenning opened this issue Jul 21, 2017 · 1 comment
Closed
3 tasks done

Request: New bind property for route parameters #972

goenning opened this issue Jul 21, 2017 · 1 comment

Comments

@goenning
Copy link
Contributor

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.

@vishr
Copy link
Member

vishr commented Jul 21, 2017

@goenning Should be ok

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

No branches or pull requests

2 participants