Documentation

binder maps the parts of an *http.Request onto the fields of a struct, using struct tags to say where each field comes from, then runs the validation your type defines. That is the whole library. It ships no rule language, and does not route, log or transform — those belong to packages that already do them well.

These pages document v1.2.0. The module path is uradical.io/go/binder and it requires Go 1.27.

The shape of it

One call, one struct. Each field names a source and a key; binder reads the request once, converts each value to the field's type, and reports every field that could not be filled, together.

type UpdateUser struct {
	ID      int      `path:"id"`
	Fields  []string `query:"fields"`
	Name    string   `body:"name,required"`
	Email   string   `body:"email,omitempty"`
	Token   string   `cookie:"session"`
	TraceID string   `header:"X-Request-ID"`
}

func handler(w http.ResponseWriter, r *http.Request) {
	var req UpdateUser
	if err := binder.Bind(r, &req); err != nil {
		http.Error(w, err.Error(), http.StatusBadRequest)
		return
	}
	// req is populated; every field came from where its tag says.
}

Start here

What binder does not do

Knowing the edges early saves an afternoon of looking for a feature that was never there:

The README in the repository is the canonical documentation and these pages track it. Where they disagree, the source wins — and please open an issue.