From 2ac34a23542c7c66427e7ca9bd33d14ba03c0dd7 Mon Sep 17 00:00:00 2001 From: Eltrac Date: Wed, 3 Dec 2025 15:21:07 +0800 Subject: doc: write doc comments for Router --- router.go | 8 ++++++++ 1 file changed, 8 insertions(+) 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) -- cgit v1.2.3