Skip to content

Commit 59ce668

Browse files
nickhudkinskisielk
authored andcommitted
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 :)
1 parent 85b8c20 commit 59ce668

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,9 +190,9 @@ func handler(w http.ResponseWriter, r *http.Request) {
190190
func main() {
191191
r := mux.NewRouter()
192192
r.HandleFunc("/", handler)
193-
r.Methods("POST").HandleFunc("/products", handler)
194-
r.Methods("GET").HandleFunc("/articles", handler)
195-
r.Methods("GET", "PUT").HandleFunc("/articles/{id}", handler)
193+
r.HandleFunc("/products", handler).Methods("POST")
194+
r.HandleFunc("/articles", handler).Methods("GET")
195+
r.HandleFunc("/articles/{id}", handler).Methods("GET", "PUT")
196196
r.Walk(func(route *mux.Route, router *mux.Router, ancestors []*mux.Route) error {
197197
t, err := route.GetPathTemplate()
198198
if err != nil {

0 commit comments

Comments
 (0)