1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
//! # Axeon
//!
//! A modern, flexible, and feature-rich web framework for Rust.
//!
//! ## Features
//!
//! - Express-style routing with support for path parameters and query parameters
//! - Modular router system with mounting capabilities
//! - Powerful middleware system for request/response processing
//! - Built-in security features and authentication support
//! - JSON request/response handling with type safety
//! - Async/await support throughout the framework
//!
//! ## Quick Start
//!
//! ```rust
//! use axeon::{Response, Server};
//!
//! fn main() {
//! let mut app = Server::new();
//! app.get("/", |_req| async {
//! Response::text("Hello, World!")
//! });
//! app.listen("127.0.0.1:3000")
//! .expect("Server failed to start");
//! }
//! ```
//!
//! ## Routing Examples
//!
//! ### Basic Routes
//!
//! ```rust
//! use axeon::{Response, Server};
//!
//! let mut app = Server::new();
//!
//! // Basic route
//! app.get("/", |_req| async {
//! Response::text("Welcome!")
//! });
//!
//! // Route with path parameter
//! app.get("/users/:id", |req| async move {
//! let user_id = req.params.get("id").unwrap();
//! Response::text(format!("User ID: {}", user_id))
//! });
//! ```
//!
//! ### JSON Handling
//!
//! ```rust
//! use axeon::{Response, Server, ServerError};
//! use serde::{Deserialize, Serialize};
//!
//! #[derive(Serialize, Deserialize)]
//! struct User {
//! name: String,
//! role: String,
//! }
//!
//! app.post("/users", |req| async move {
//! match req.body.json::<User>() {
//! Some(user) => Response::ok(&user),
//! None => Err(ServerError::BadRequest("Invalid JSON body".to_string())),
//! }
//! });
//! ```
//!
//! ## Middleware System
//!
//! ```rust
//! use axeon::{Request, Response, ServerError};
//! use axeon::middleware::{Middleware, MiddlewareResult, Next};
//! use std::time::Instant;
//!
//! // Example logging middleware
//! struct Logger;
//! impl Middleware for Logger {
//! fn call(&self, req: Request, next: Next) -> MiddlewareResult {
//! Box::pin(async move {
//! let start = Instant::now();
//! let method = req.method.clone();
//! let url = req.path.clone();
//!
//! let res = next.handle(req).await;
//!
//! let status = match &res {
//! Ok(res) => res.status,
//! Err(err) => err.status_code(),
//! };
//! println!("[{}] {:?} {} - {}ms", status, method, url, start.elapsed().as_millis());
//! res
//! })
//! }
//!
//! fn clone_box(&self) -> Box<dyn Middleware> {
//! Box::new(Self)
//! }
//! }
//! ```
//!
//! ## Router Groups
//!
//! ```rust
//! use axeon::{Router, Server, Response};
//!
//! let mut app = Server::new();
//! let mut api = Router::new();
//!
//! // API routes
//! api.get("/status", |_req| async {
//! Response::ok(&serde_json::json!({
//! "status": "operational",
//! "version": "1.0.0"
//! }))
//! });
//!
//! // Mount API routes with prefix
//! app.mount("/api", api);
//! ```
//!
pub extern crate serde_json;
pub
pub
pub
pub
pub
pub
pub use Server;
pub use Router;
pub use crateServerError;
pub use crate;
pub use crateResponse;
// Reexport serde_json
pub use ;