Skip to content

Commit b128961

Browse files
authored
Merge pull request #199 from wirehead/minor-doc-tweek
Clarify how route variables work. (#151)
2 parents 34dda71 + 910dd3a commit b128961

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,11 @@ r.HandleFunc("/articles/{category}/{id:[0-9]+}", ArticleHandler)
6565
The names are used to create a map of route variables which can be retrieved calling `mux.Vars()`:
6666

6767
```go
68-
vars := mux.Vars(request)
69-
category := vars["category"]
68+
func ArticlesCategoryHandler(w http.ResponseWriter, r *http.Request) {
69+
vars := mux.Vars(r)
70+
w.WriteHeader(http.StatusOK)
71+
fmt.Fprintf(w, "Category: %v\n", vars["category"])
72+
}
7073
```
7174

7275
And this is all you need to know about the basic usage. More advanced options are explained below.

0 commit comments

Comments
 (0)