# [examples](https://gitea.com/rustacean/athene-example.git) # ⚡️ Quick Start ## use athene's full feature ````rust use athene::prelude::*; #[derive(Debug, Serialize, Deserialize, Validate, Default)] pub struct UserController { #[validate(email)] pub email: String, // admin@outlook.com #[validate(range(min = 18, max = 20))] pub age: u16, } // http://127.0.0.1:7878/api/v1/user #[controller(prefix = "api", version = 1, name = "user")] impl UserController { // http://127.0.0.1:7878/api/v1/user/admin@outlook.com/18 // Uri Path Params #[delete("/{email}/{age}")] pub async fn delete(&self, email: String, age: Option) -> impl Responder { ( StatusCode::OK, format!("email is : {}, and age is : {:?}", email, age), ) } // http://127.0.0.1:7878/api/v1/user/query_get/?email=admin@outlook.com&age=29 // Query Params #[get("/query_get")] pub async fn query_get(&self, email: String, age: u16) -> impl Responder { let user = Self { email, age }; user.validate()?; // user will be validate Ok::<_, Error>((200, Json(user))) } // http://127.0.0.1:7878/api/v1/user/query/?email=admin@outlook.com&age=19 // Query Params #[get("/query")] // user will be validate pub async fn query(&self, user: Query) -> impl Responder { (200, Json(user.0)) } // http://127.0.0.1:7878/api/v1/user/create // Context-Type : application/json #[post("/create")] // user will be validate async fn create(&self, user: Json) -> impl Responder { Ok::<_, Error>((200, user)) } // http://127.0.0.1:7878/api/v1/user/update // Context-Type : application/x-www-form-urlencoded #[put("/update")] #[validator(exclude("user"))] // user will not be validate async fn update(&self, user: Form) -> impl Responder { Ok::<_, Error>((200, user)) } } #[tokio::main] pub async fn main() -> Result<()> { // Add Router let app = athene::new().router(upload_router).router(|r|r.controller(UserController::default())); // Start Server app.listen("127.0.0.1:7878").await } `````