Skip to content

Commit 757bef9

Browse files
authored
Merge pull request #196 from olt/doc-non-capture-groups
document non-capturing groups (closes #143)
2 parents 0a192a1 + 14f5df0 commit 757bef9

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

doc.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ variable will be anything until the next slash. For example:
4747
r.HandleFunc("/articles/{category}/", ArticlesCategoryHandler)
4848
r.HandleFunc("/articles/{category}/{id:[0-9]+}", ArticleHandler)
4949
50+
Groups can be used inside patterns, as long as they are non-capturing (?:re). For example:
51+
52+
r.HandleFunc("/articles/{category}/{sort:(?:asc|desc|new)}", ArticlesCategoryHandler)
53+
5054
The names are used to create a map of route variables which can be retrieved
5155
calling mux.Vars():
5256

0 commit comments

Comments
 (0)