Skip to content

Commit

Permalink
[docs] Document evaluation order for routes (gorilla#297)
Browse files Browse the repository at this point in the history
  • Loading branch information
mmdriley authored and elithrar committed Sep 22, 2017
1 parent 24fca30 commit 3f19343
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ r.HandleFunc("/products", ProductsHandler).
Schemes("http")
```

Routes are tested in the order they were added to the router. If two routes match, the first one wins:

```go
r := mux.NewRouter()
r.HandleFunc("/specific", specificHandler)
r.PathPrefix("/").Handler(catchAllHandler)
```

Setting the same matching conditions again and again can be boring, so we have a way to group several routes that share the same requirements. We call it "subrouting".

For example, let's say we have several URLs that should only match when the host is `www.example.com`. Create a route for that host and get a "subrouter" from it:
Expand Down

0 comments on commit 3f19343

Please sign in to comment.