about summary refs log tree commit diff
path: root/README.md
diff options
context:
space:
mode:
authorFranck Cuny <franck@lumberjaph.net>2013-04-27 10:05:39 -0700
committerFranck Cuny <franck@lumberjaph.net>2013-04-27 10:05:39 -0700
commit54f364f2c79dc76d0277d2d3db5275c4c6030129 (patch)
tree7765f7f9345df1882f4f180bd9004d37b5eefe7f /README.md
parentRename all instances of Dispatcher to Router. (diff)
downloadpath-router-54f364f2c79dc76d0277d2d3db5275c4c6030129.tar.gz
Add exemple for validations in the README.
Diffstat (limited to 'README.md')
-rw-r--r--README.md20
1 files changed, 20 insertions, 0 deletions
diff --git a/README.md b/README.md
index ea50562..8aab966 100644
--- a/README.md
+++ b/README.md
@@ -36,6 +36,26 @@ or:
 
 The attribute Validations is optional, but all the keys defined in the map need to be parameters in the URL.
 
+If you use validation, you can write this kind of route with no ambiguity:
+
+    &Route{
+        Method: "GET",
+        Path: "/user/:id",
+        Code: GetUserById,
+        Validations: map[string]*regexp.Regexp{
+            "id": regexp.MustCompile("[\\d]+"),
+        }
+    }
+
+    &Route{
+        Method: "GET",
+        Path: "/user/:name",
+        Code: GetUserByName,
+        Validations: map[string]*regexp.Regexp{
+            "id": regexp.MustCompile("[a-zA-Z]+"),
+        }
+    }
+
 ## External links
 
 * [Build status](https://drone.io/github.com/franckcuny/mooh/latest)