ohkami - [狼] means wolf in Japanese - is simple and macro free web framework for Rust.
Features
- simple: Less things to learn / Less code to write / Less time to hesitate.
- macro free: No need for using macros.
- async handlers
- easy error handling
Quick start
- Add dependencies:
[]
= "0.3"
- Write your first code with ohkami:
use *;
- If you're interested in ohkami, learn more by examples and documentation!
Snippets
handle query params
let name = ctx.?;
// if presumable, `::<&str>` isn't needed
let count = ctx.?;
// if presumable, `::<usize>` isn't needed
handle request body
let body = ctx.?;
// if presumable, `::<D>` isn't needed
// `D` has to be `serde::Deserialize`
handle path params
async
return OK response with text/plain
OK
return OK response with application/json
OK
OK
OK
// serialize Rust value into JSON
// value's type has to be `serde::Serialize`
handle errors
let user = ctx.?;
// or, you can add an error context message:
let user = ctx.
._else?;
// or discard original error:
let user = ctx.
._else?;
// or
._else?;
handle Option values
let handler = self.handler.as_ref._else?;
assert boolean conditions
._else?;
// or
._else?;
log config
DB config
let config = Config ;
use sqlx
let user = .bind
.fetch_one
.await?; // `Response` implements `From<sqlx::Error>`
test
- split setup process from
mainfunction:
- write tests using
assert_to_res,assert_not_to_res:
Development
ohkami is on early stage now and not for producntion use.
Please give me your feedback! → GetHub issue
License
This project is under MIT LICENSE (LICENSE-MIT or https://opensource.org/licenses/MIT).