routes!() { /* proc-macro */ }Expand description
Creates a new Router instance.
This is a simple convenience macro that expands to Router::new().
It’s provided for consistency with potential future routing macros
that may accept declarative route definitions.
§Usage
use wsforge_macros::routes;
let router = routes!();
// Equivalent to: Router::new()§Future Enhancement
This macro may be extended in the future to support declarative routing:
let router = routes! {
"/echo" => echo_handler,
"/chat" => chat_handler,
"/api/*" => api_handler,
};§Examples
§Current Usage
use wsforge_macros::routes;
use wsforge_core::prelude::*;
async fn handler(msg: Message) -> Result<String> {
Ok("response".to_string())
}
let router = routes!()
.route("/echo", handler(handler));
router.listen("127.0.0.1:8080").await?;