use elif_http_derive::{controller, get, middleware, post};
pub struct UserController;
impl UserController {
#[get("")]
pub async fn list(&self, _req: String) -> Result<String, String> {
Ok("User list".to_string())
}
#[get("/{id}")]
pub async fn show(&self, _req: String) -> Result<String, String> {
Ok("User details".to_string())
}
#[post("")]
#[middleware("auth")]
pub async fn create(&self, _req: String) -> Result<String, String> {
Ok("User created".to_string())
}
}
#[controller("/api/legacy")]
pub struct LegacyController;
#[test]
fn test_legacy_controller_constants() {
assert_eq!(LegacyController::BASE_PATH, "/api/legacy");
assert_eq!(LegacyController::CONTROLLER_NAME, "LegacyController");
}
pub struct AdminController;
impl AdminController {
#[get("/dashboard")]
#[middleware("auth", "admin")]
pub async fn dashboard(&self, _req: String) -> Result<String, String> {
Ok("Admin dashboard".to_string())
}
#[post("/settings")]
#[middleware("auth", "admin", "csrf")]
pub async fn update_settings(&self, _req: String) -> Result<String, String> {
Ok("Settings updated".to_string())
}
}
#[controller("/empty")]
pub struct EmptyController;
#[test]
fn test_empty_controller_constants() {
assert_eq!(EmptyController::BASE_PATH, "/empty");
assert_eq!(EmptyController::CONTROLLER_NAME, "EmptyController");
}