unmbt/ciallo/router does not have a README file

    RouteConflict

    pub(all) suberror RouteConflict {
    DuplicateRoute(meth~ :
    Method
    , path~ : String)
    AmbiguousParam(path~ : String, existing~ : String, incoming~ : String)
    InvalidPattern(pattern~ : String, reason~ : String)
    } derive(Eq,
    Debug
    )

    RouteMatch

    pub(all) struct RouteMatch[T] {
    value : T
    params : RouteParams
    pattern : String
    } derive(Eq,
    Debug
    )

    RouteParams

    pub(all) struct RouteParams {
    values : Array[(String, String)]
    } derive(Eq,
    Debug
    )

    RouteParams::RouteParams

    fn RouteParams::RouteParams(values? : Array[(String, String)]) -> RouteParams

    RouteParams::entries

    fn RouteParams::entries(self : RouteParams) -> Array[(String, String)]

    RouteParams::get

    fn RouteParams::get(self : RouteParams, name : StringView) -> String?

    Router

    pub struct Router[T] {
    // private fields
    }

    Radix/Trie 路由表(不透明类型,分段匹配完成后再对单段参数做 RFC 3986 解码以防 %2F 穿越)

    Router::Router

    fn[T] Router::Router() -> Router[T]

    Router::add

    fn[T] Router::add(self : Router[T], meth :
    Method
    , pattern : StringView, value : T) -> Unit raise RouteConflict

    Router::allowed_methods

    fn[T] Router::allowed_methods(self : Router[T], path : StringView) -> Array[
    Method
    ]

    Router::match_route

    fn[T] Router::match_route(self : Router[T], meth :
    Method
    , path : StringView) -> RouteMatch[T]? raise
    UrlError

    Router::routes

    fn[T] Router::routes(self : Router[T]) -> Array[(
    Method
    , String)]

    Source Files