Skip to content

Commit

Permalink
Merge pull request #199 from wirehead/minor-doc-tweek
Browse files Browse the repository at this point in the history
Clarify how route variables work. (#151)
  • Loading branch information
kisielk committed Jan 17, 2017
2 parents 34dda71 + 910dd3a commit b128961
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,11 @@ r.HandleFunc("/articles/{category}/{id:[0-9]+}", ArticleHandler)
The names are used to create a map of route variables which can be retrieved calling `mux.Vars()`:

```go
vars := mux.Vars(request)
category := vars["category"]
func ArticlesCategoryHandler(w http.ResponseWriter, r *http.Request) {
vars := mux.Vars(r)
w.WriteHeader(http.StatusOK)
fmt.Fprintf(w, "Category: %v\n", vars["category"])
}
```

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

0 comments on commit b128961

Please sign in to comment.