summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--router.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/router.go b/router.go
index d17d132..c5e8933 100644
--- a/router.go
+++ b/router.go
@@ -8,11 +8,19 @@ func NewRouter() *Router {
return &Router{}
}
+// Router.Add adds a route with specified method, path and handler
+// it splits path into segments for matching
func (r *Router) Add(method string, path string, h Handler) {
parts, _ := ParsePath(path)
r.routes = append(r.routes, Route{method, parts, h})
}
+// Router.Find finds route with same HTTP method and path
+// returns the handler, parameters and query
+//
+// handler is a function that wraps Context
+// params is a map of parameters from dynamic routing
+// query is a map of query parameters from URL
func (r *Router) Find(method string, path string) (
handler Handler, params map[string]string, query map[string]string) {
parts, query := ParsePath(path)