Skip to content

Commit 3f19343

Browse files
mmdrileyelithrar
authored andcommitted
[docs] Document evaluation order for routes (#297)
1 parent 24fca30 commit 3f19343

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,14 @@ r.HandleFunc("/products", ProductsHandler).
135135
Schemes("http")
136136
```
137137

138+
Routes are tested in the order they were added to the router. If two routes match, the first one wins:
139+
140+
```go
141+
r := mux.NewRouter()
142+
r.HandleFunc("/specific", specificHandler)
143+
r.PathPrefix("/").Handler(catchAllHandler)
144+
```
145+
138146
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".
139147

140148
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:

0 commit comments

Comments
 (0)