Sign in

    mizchi/mars/router does not have a README file

    Router

    pub(open) trait Router {
    name(Self) -> String
    add(Self, Method, String) -> HandlerId
    match_(Self, Method, String) -> MatchResult[HandlerId]
    }

    Router trait for HTTP routing The router stores handlers by ID, and the actual handler lookup is done externally

    HandlerId

    pub(all) type HandlerId Int

    Handler ID for storing handlers
    impl Eq for HandlerId
    impl Hash for HandlerId
    impl Show for HandlerId

    HandlerId::inner

    #deprecated("Use `struct T(A)` to declare a newtype and use `.0` access the underlying type instead.")
    fn HandlerId::inner(self : HandlerId) -> Int
    Convert newtype to its underlying type, automatically derived.

    MatchResult

    pub(all) struct MatchResult[H] {
    handlers : Array[(H, Params)]
    }

    Result of route matching

    MatchResult::empty

    fn[H] MatchResult::empty() -> MatchResult[H]

    Create an empty match result

    MatchResult::is_empty

    fn[H] MatchResult::is_empty(self : MatchResult[H]) -> Bool

    Check if match result has any handlers

    Method

    pub(all) enum Method {
    Get
    Post
    Put
    Delete
    Patch
    Head
    Options
    Connect
    Trace
    Query
    All
    }

    HTTP method type
    impl Eq for Method
    impl Hash for Method
    impl Show for Method

    Method::from_string

    fn Method::from_string(s : String) -> Method?

    Parse string to Method

    Method::to_string

    fn Method::to_string(self : Method) -> String

    Convert Method to string

    Params

    pub(all) struct Params {
    // private fields
    }

    URL path parameters extracted from route matching
    impl Show for Params

    Params::clone

    fn Params::clone(self : Params) -> Params

    Clone params

    Params::get

    fn Params::get(self : Params, key : String) -> String?

    Get a parameter value by key

    Params::is_empty

    fn Params::is_empty(self : Params) -> Bool

    Check if params is empty

    Params::new

    fn Params::new() -> Params

    Create a new empty Params

    Params::set

    fn Params::set(self : Params, key : String, value : String) -> Unit

    Set a parameter value

    Params::to_map

    fn Params::to_map(self : Params) -> Map[String, String]

    Get the underlying map

    Params::with_param

    fn Params::with_param(self : Params, key : String, value : String) -> Params

    Create a new Params with an additional key-value pair More efficient than clone + set when adding a single param

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io