class
Fossil::Router
- Fossil::Router
- Reference
- Object
Overview
Router class. A instance of a class is a node in a route tree.
Defined in:
router.crConstructors
-
.new(path : Nil | String = nil, parameter : Nil | String = nil)
Initializer for
Router
.
Instance Method Summary
-
#/(other : String) : self
New
Router
s are implicitly created with calling a slash operator. -
#children : Array(Router)
Router
s that may can go afterself
and do not start with a path parameter. -
#children=(children : Array(Router))
Router
s that may can go afterself
and do not start with a path parameter. - #endpoints : Hash(Fossil::MethodsEnum, Fossil::Endpoint)
- #endpoints=(endpoints : Hash(Fossil::MethodsEnum, Fossil::Endpoint))
-
#param_children : Hash(Fossil::Param::PathParamTypeEnum, Router)
Router
s that may can go afterself
and do start with a path parameter. -
#param_children=(param_children : Hash(Fossil::Param::PathParamTypeEnum, Router))
Router
s that may can go afterself
and do start with a path parameter. -
#parameter : Nil | String
Name of a path parameter a path that can be resolved to one of the endpoints down the tree from the current node starts with.
-
#path : Nil | String
The first path fragment of a path that can be resolved to one of the endpoints down the tree from the current node.
-
#trace(path : String, path_params = {} of String => Fossil::Param::PathParamType) : Tuple(Router, Hash(String, Fossil::Param::PathParamType))
Trace
#path
down the tree from the current router and pass all found path parameters inpath_params
.
Constructor Detail
Instance Method Detail
New Router
s are implicitly created with calling a slash operator.
root = Fossil::Router.new ""
root / "route_a/its_child"
root / "route_b/@param1:int/info"
Router
s that may can go after self
and do start with a path parameter.
Type of a parameter is a key in a Hash
, so its capacity is equal to 3.
Router
s that may can go after self
and do start with a path parameter.
Type of a parameter is a key in a Hash
, so its capacity is equal to 3.
Name of a path parameter a path that can be resolved to one of the endpoints down the tree from the current node starts with.
While @path
is a whole fragment between two slashes, @parameter
is parsed from a fragment "@<parameter_name>:<parameter_type>",
where <parameter_type> is of type Fossil::Param::PathParamTypeEnum
(string that can be parsed to this enum).
The first path fragment of a path that can be resolved to one of the endpoints down the tree from the current node.
If @path.is_nil
the fragment is a path parameter.
Trace #path
down the tree from the current router and pass all found path parameters in path_params
.