Skip to content

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

@pafuent

Description

@pafuent

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions