Browse Source

Fix invalid example code

In the "List Routes" example code, `.HandleFunc` was being called on a `*mux.Route` rather than `*mux.Router`. Updated the example code to work :)
pull/270/head
Nick Hudkins 9 years ago committed by Kamil Kisiel
parent
commit
59ce66852b
  1. 6
      README.md

6
README.md

@ -190,9 +190,9 @@ func handler(w http.ResponseWriter, r *http.Request) { @@ -190,9 +190,9 @@ func handler(w http.ResponseWriter, r *http.Request) {
func main() {
r := mux.NewRouter()
r.HandleFunc("/", handler)
r.Methods("POST").HandleFunc("/products", handler)
r.Methods("GET").HandleFunc("/articles", handler)
r.Methods("GET", "PUT").HandleFunc("/articles/{id}", handler)
r.HandleFunc("/products", handler).Methods("POST")
r.HandleFunc("/articles", handler).Methods("GET")
r.HandleFunc("/articles/{id}", handler).Methods("GET", "PUT")
r.Walk(func(route *mux.Route, router *mux.Router, ancestors []*mux.Route) error {
t, err := route.GetPathTemplate()
if err != nil {

Loading…
Cancel
Save