Skip to content

E0405: A handler parameter can't be bound ​

A hook's or handler's parameters are filled by type: context.Context, *http.Request, one struct (or url.Values) from the request's body or form — on a live page, the event's form —, scalars from the path or query (on a live page, the event's value), and types the app provides. This parameter is none of them: a type a request can't carry (chan int), a second struct, a second value from a live event, a hook's parameter that isn't the context or a provided type, or, in a handler registered from Go, a scalar with no path segment left to bind (reflection can't see names: Go takes the query in a struct). Reported at boot, at the handler's file and line, and by vukavet.

Wrong ​

vuka
@web.Post("/pets")
func AddPet(p Pet, owner Owner) Result[Pet] { … }
go
func SearchPets(q string, store *PetStore) ([]Pet, error) { return store.Search(q) }

func init() {
	web.Routes.Get("/pets", SearchPets) // q has no name and no segment: reflection can't see it
}
vuka
@web.Post("/pets")
func AddPet(p Pet, owners *Owners) Result[Pet] { … }
go
type Search struct {
	Q string `form:"q"`
}

func SearchPets(s Search, store *PetStore) ([]Pet, error) { return store.Search(s.Q) }

func init() {
	web.Routes.Get("/pets", SearchPets)
}

Released under the MIT License. Vuka builds on Go and its tools, which are made by the Go Authors. Vuka is not affiliated with Google or the Go project. Go is a trademark of Google LLC.