Skip to content

E0401: A route is declared twice ​

Two handlers declare the same method and path, so a request can't tell them apart. Both places are shown. Reported at boot, and by vukavet.

Wrong ​

vuka
@web.Get("/pets")
func ListPets(store *PetStore) []Pet { … }

@web.Get("/pets")
func AdminPets(store *PetStore) []Pet { … }
go
func init() {
	web.Routes.Get("/pets", ListPets)
	web.Routes.Get("/pets", AdminPets)
}
vuka
@web.Get("/pets")
func ListPets(store *PetStore) []Pet { … }

@web.Get("/admin/pets")
func AdminPets(store *PetStore) []Pet { … }
go
func init() {
	web.Routes.Get("/pets", ListPets)
	web.Routes.Get("/admin/pets", AdminPets)
}

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.