class
LuckyRouter::Matcher(T)
- LuckyRouter::Matcher(T)
- Reference
- Object
Overview
Add routes and match routes
'T' is the type of the 'payload'. The 'payload' is what will be returned if the route matches.
Example
# 'T' will be 'Symbol'
router = LuckyRouter::Matcher(Symbol).new
# Tell the router what payload to return if matched
router.add("get", "/users", :index)
# This will return :index
router.match("get", "/users").payload # :index
Defined in:
lucky_router/matcher.crInstance Method Summary
- #add(method : String, path : String, payload : T)
-
#compile(*, static_index : Bool = true) : CompiledMatcher(T)
Freeze the current routing structure for optional static indexing and compact traversal.
-
#list_routes : Array(Tuple(String, String, T))
Array of the path, method, and payload
- #match(method : String, path_to_match : String) : Match(T) | Nil
- #match!(method : String, path_to_match : String) : Match(T)
-
#match_payload(method : String, path_to_match : String) : T | Nil
Match without constructing a parameter hash or copying captured strings.
- #normalized_paths
-
#root
starting point from which all fragments are located
Instance Method Detail
Freeze the current routing structure for optional static indexing and compact traversal. Later mutations require creating another snapshot. Disable the exact static index when an integrating framework already handles those paths. Static routes still match through the compact trie.
Array of the path, method, and payload
Match without constructing a parameter hash or copying captured strings.