mizchi/mars/router/trie does not have a README file

    HandlerParamsSet

    pub(all) struct HandlerParamsSet {
    handler_id : Int
    params :
    Params

    score : Int
    possible_keys : Array[String]
    }

    Handler with extracted parameters

    HandlerSet

    pub(all) struct HandlerSet {
    handler_id : Int
    possible_keys : Array[String]
    score : Int
    }

    Handler set with metadata for scoring

    Node

    pub(all) struct Node {
    methods : Map[String, Array[HandlerSet]]
    children : Map[String, Node]
    patterns : Array[Pattern]
    }

    Trie node for URL routing

    Node::insert

    fn Node::insert(self : Node, meth : String, path : String, handler_id : Int, order : Int) -> Int

    Insert a route into the trie Returns the score (order) of the inserted handler

    Node::new

    fn Node::new() -> Node

    Create a new empty node

    Node::search

    fn Node::search(self : Node, meth : String, path : String) -> Array[HandlerParamsSet]

    Search for matching handlers

    Node::with_handler

    fn Node::with_handler(meth : String, handler_id : Int) -> Node

    Create a new node with an initial method and handler

    Pattern

    pub(all) enum Pattern {
    Wildcard
    Param(String)
    ParamWithRegex(String, String)
    }

    Pattern types for URL matching
    impl Eq for Pattern
    impl Show for Pattern

    TrieRouter

    pub(all) struct TrieRouter {
    root : Node
    order : Int
    }

    TrieRouter - A trie-based HTTP router

    TrieRouter::add

    Add a route to the router

    TrieRouter::match_

    Match a request path against registered routes

    TrieRouter::name

    fn TrieRouter::name(_self : TrieRouter) -> String

    Get the router name

    TrieRouter::new

    fn TrieRouter::new() -> TrieRouter

    Create a new TrieRouter

    check_optional_parameter

    fn check_optional_parameter(path : String) -> Array[String]?

    Check for optional parameters in path "/api/animals/:type?" => ["/api/animals", "/api/animals/:type"] Returns None if path doesn't end with optional parameter

    get_pattern

    fn get_pattern(label : String) -> Pattern?

    Get pattern from a path segment Returns None for static segments "*" => Wildcard ":id" => Param("id") ":id{[0-9]+}" => ParamWithRegex("id", "[0-9]+")

    split_path

    fn split_path(path : String) -> Array[String]

    Split a URL path into segments "/hello/world" => ["hello", "world"] "/" => []

    split_routing_path

    fn split_routing_path(route_path : String) -> Array[String]

    Split a routing path with group marker preservation This handles regex patterns in braces like :id{[0-9]+}

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io