dce_router/
lib.rs

1//! # Dce Router
2//!
3//! Dce router is the core feature of dce framework, it can help you do api routing in any type and any framework (not only with Dce) program coding.
4//!
5//! ## Features
6//!
7//! - `default`: `["async"]`
8//! - `async`: You can define both async and normal sync fn as controller if this enabled, or just allow sync controller
9//!
10//! ## Examples
11//!
12//! ```passed
13//! use dce_macro::api;
14//! use dce_router::router::Router;
15//! use dce_cli::protocol::{CliProtocol, CliRaw};
16//!
17//! #[tokio::main]
18//! async fn main() {
19//!     let router = Router::new()
20//!         .push(sync)
21//!         .push(a_sync)
22//!         .ready();
23//!     CliProtocol::new(1).route(router.clone(), Default::default()).await;
24//! }
25//!
26//! #[api]
27//! pub fn sync(req: CliRaw) {
28//!     req.end(None)
29//! }
30//!
31//! #[api]
32//! pub async fn a_sync(req: CliRaw) {
33//!     req.raw_resp("Hello world !".to_string())
34//! }
35//! ```
36//!
37
38
39pub mod api;
40pub mod request;
41pub mod router;
42pub mod serializer;
43pub mod protocol;