From 54f364f2c79dc76d0277d2d3db5275c4c6030129 Mon Sep 17 00:00:00 2001 From: Franck Cuny Date: Sat, 27 Apr 2013 10:05:39 -0700 Subject: Add exemple for validations in the README. --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'README.md') 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) -- cgit 1.4.1