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

Document how to bind multiple instances of the same query param to a slice #170

Open
pafuent opened this issue Dec 15, 2020 · 1 comment

Comments

@pafuent
Copy link
Contributor

pafuent commented Dec 15, 2020

Add documentation about how to bind multiple instances of the same query parameter to a slice.
Use this UT as a reference (if it is possible make a more real example than this 😉)

func TestBindSlices(t *testing.T) {
	e := New()
	req := httptest.NewRequest(GET, "/?str=foo&str=bar&str=foobar", nil)
	rec := httptest.NewRecorder()
	c := e.NewContext(req, rec)
	result := struct {
		Str []string `query:"str"`
	}{}
	err := c.Bind(&result)
	if assert.NoError(t, err) {
		assert.Equal(t, []string{"foo", "bar", "foobar"}, result.Str)
	}
}

Binding documentation is in https://github.com/labstack/echox/blob/master/website/content/guide/request.md

@sunecko
Copy link

sunecko commented Nov 18, 2023

I can take care of this, this will be my first contribution

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

No branches or pull requests

2 participants