|
|
|
@ -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()`: |
|
|
|
The names are used to create a map of route variables which can be retrieved calling `mux.Vars()`: |
|
|
|
|
|
|
|
|
|
|
|
```go |
|
|
|
```go |
|
|
|
vars := mux.Vars(request) |
|
|
|
func ArticlesCategoryHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
category := vars["category"] |
|
|
|
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. |
|
|
|
And this is all you need to know about the basic usage. More advanced options are explained below. |
|
|
|
|