# Aqua **Repository Path**: MoleSir/aqua ## Basic Information - **Project Name**: Aqua - **Description**: A simple web framework for learning. - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 1 - **Forks**: 0 - **Created**: 2025-06-09 - **Last Updated**: 2025-06-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: Http, Rust, Server, client ## README # Aqua A simple web framework for learning. ## Features - [x] http lib - [x] server dynamic route - [x] server shared state - [x] server use http body - [x] server response resources - [x] server handle define status code(handle failed) - [x] server support query - [x] better error message in macros - [x] server async - [x] simple client send http request - [x] client keep alive - [x] websocket server & client - [x] websocket handle Available feature flags: | Feature | Description | | ----------------------- | ----------------------------------------------- | | `server` | Enable HTTP server modules | | `client` | Enable HTTP client modules | | `full` | Enable both server and client | | `enable-default-logger` | Enable default logging via `tracing-subscriber` | # Example ## Server A simple http server like rocket. (Nee to enable server feature) ````rust use aqua::server::prelude::*; #[get(path = "/hello/")] fn hello(name: String) -> String { format!("Hello {}", name) } // /query/baidu?name=yc&age=23&score=1.2 #[get(path = "/query/", query = "name&age&score")] fn with_query(engine: String, name: String, age: i32, score: f64) -> String { format!("Search: {name} {age} {score} from {engine}") } ```` ## Client A simple http client like reqwest. (Nee to enable client feature) ```rust use aqua::client::prelude::*; let response: HttpResponse = Client::get() .uri("http://httpbin.org/get?foo=bar").unwrap() .send() .await .unwrap(); ``` Or create a keep-alive client: ```rust use aqua::client::prelude::*; let client = Client::connect("127.0.0.1:7979").await?; // No need to indicate host in `uri` client.send( HttpRequest::builder().method(HttpMethod::Get).path("/index").unwrap().build().unwrap() ).await?; ``` Upgrade to websocket! ```rust use aqua::client::prelude::*; let client = Client::connect("127.0.0.1:7979").await?; let mut client = client.upgrade_websocket().await?; client.start_handle(ChatRoomHandler::new()); // Use websocket now client.send_text("hello").await?; ``` # LICENSE This project is licensed under the [MIT](./LICENSE) # Reference - https://github.com/hyperium/http - https://rocket.rs/ - https://en.wikipedia.org/wiki/HTTP - https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/Overview