| Crates.io | kurosabi |
| lib.rs | kurosabi |
| version | 0.6.13 |
| created_at | 2025-03-21 14:32:23.231215+00 |
| updated_at | 2026-01-17 19:12:36.981765+00 |
| description | A lightweight asynchronous HTTP server framework built on Tokio. |
| homepage | |
| repository | https://github.com/371tti/kurosabi |
| max_upload_size | |
| id | 1600557 |
| size | 166,850 |
kurosabiは、Rustの安全性と並列性を活かした、超軽量・高速・シンプルなWebバックエンドルーターです。
パフォーマンスと軽量さ、書きやすさ、シンプルさを大事にします
超軽量・高速・小依存
シンプルで表現力の高いルーティング
非同期ハンドラ対応
JSON・ファイルレスポンス
カスタムコンテキスト対応
404やエラー処理が簡単
Cargo.tomlに以下を追加してください:
[dependencies]
kurosabi = "0.6"
以下のコマンドでexamplesのデモを見れます。
cargo run --example hello --features="tokio-server"
tokioでの場合
[dependencies]
kurosabi = { version = "0.6", features = ["tokio-server"] }
use std::io::Result;
use kurosabi::{http::HttpMethod, server::tokio::KurosabiTokioServerBuilder};
#[tokio::main(flavor = "multi_thread", worker_threads = 16)]
async fn main() -> Result<()> {
let server = KurosabiTokioServerBuilder::default()
.bind([0, 0, 0, 0])
.port(8080)
.router_and_build(|conn| async move {
match conn.req.method() {
HttpMethod::GET => match conn.path_segs().as_ref() {
// GET /hello
["hello"] => conn.text_body("Hello, World!"),
// GET /hello/:name
["hello", name] => {
let body = format!("Hello, {}!", name);
conn.text_body(body)
},
// GET /anything/:anything...
["anything", others @ ..] => {
let own: String = others.join("/");
conn.text_body(format!("You requested anything/{}!", own))
},
// GET /
[""] => conn.text_body("Welcome to the Kurosabi HTTP Server!"),
// その他は404
_ => conn.set_status_code(404u16).no_body(),
},
// GET以外を405
_ => conn.set_status_code(405u16).no_body(),
}
},
);
server.run().await
}
提案があればぜひissueへ
プルリクもまってます
MIT