ohkami - [狼] means wolf in Japanese - is simple and non macro-based web framework for Rust.
toml
[dependencies]
ohkami = "0.1"
```rust use ohkami::prelude::*;
fn main() -> Result<()> { Server::setup() .GET("/", || async {Response::OK("Hello, world!")}) .serveon(":3000") } ```
rust
let param: Option<&str> = ctx.param();
// current ohkami only supports single path param at the end of a path
rust
let query: Option<&str> = ctx.query("key");
rust
let body: Result<D> = ctx.body::<D>();
text/plain
rust
Response::OK("Hello, world!")
application/json
rust
Response::OK(JSON("Hello, world!"))
rust
Response::OK(json!("ok": true))
rust
Response::OK(json(user)?) // serialize Rust value into JSON
rust
let count = ctx.query("count")
._else(|| Response::BadRequest("expected query param `count`"))?
.parse::<usize>()
._else(|_| Response::BadRequest("`count` must be an integer"))?;
``rust
let user = ctx.body::<User>()?;
//
Responseimplements
From
// or, you can add an error context message:
let user = ctx.body::
ohkami is on very early stage now and not for producntion use.
This project is under MIT LICENSE (LICENSE-MIT or https://opensource.org/licenses/MIT).