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. That is the whole library. It does not validate, route, log or transform — those belong to packages that already do them well.

These pages document v1.1.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 the first field that could not be filled.

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.