Crates.io | sword |
lib.rs | sword |
version | 0.1.8 |
created_at | 2025-06-19 06:07:54.663004+00 |
updated_at | 2025-09-14 20:13:39.166349+00 |
description | A structured rust web framework built on top of Axum, providing clean routing, configuration, and middleware support |
homepage | https://github.com/sword-framework/sword |
repository | https://github.com/sword-framework/sword |
max_upload_size | |
id | 1717866 |
size | 146,658 |
Structured web framework for rust built on top of axum.
Designed to build server application with less boilerplate and more simplicity.
It takes advantage of the tokio ecosystem to bring you performance with nice DX.
serde
and validator
cratesaxum_responses
crateContext
object with utility methods for request handlingshaku
crateaxum
and tokio
Cargo.toml
[dependencies]
sword = "0.1.8"
# Data serialization and deserialization
serde = { version = "*", features = ["derive"] }
# JSON data handling
serde_json = "*"
# Data validation and schema definition
validator = { version = "*", features = ["derive"] }
use sword::prelude::*;
use serde_json::Value;
#[controller("/")]
struct AppController {}
#[routes]
impl AppController {
#[get("/hello")]
async fn hello() -> HttpResponse {
HttpResponse::Ok().message("Hello, World!")
}
#[post("/submit")]
async fn submit_data(ctx: Context) -> HttpResult<HttpResponse> {
let body = ctx.body::<Value>()?;
Ok(HttpResponse::Ok()
.data(body)
.message("Data submitted successfully"))
}
}
#[sword::main]
async fn main() {
let app = Application::builder()?
.with_controller::<AppController>()
.build();
app.run().await?;
}
See the examples directory for more advanced usage.
See CHANGELOG.md for more details.
Contributions are welcome! Please open an issue or submit a pull request. See CONTRIBUTING.md for more details.