ohkami - [狼] means wolf in Japanese - is simple and non macro-based web framework for Rust.
Features
- simple: Less things to learn / Less code to write / Less time to hesitate.
- non macro-based: No need for using macros.
- async handlers
- easy error handling
Quick start
- Add dependencies:
[]
= "0.1"
- Write your first code with ohkami:
use *;
- If you're interested in ohkami, learn more by examples and documentations(WIP)!
Snippets
get path param
let param: = ctx.param;
// current ohkami only supports single path param at the end of a path
get query param
let query: = ctx.query;
deserialize request body
let body: = ctx.;
return OK response with text/plain
OK
return OK response with application/json
OK
OK
OK // serialize Rust value into JSON
error handling
let count = ctx.query?.
._else?;
let user = ctx.?;
// or, you can add an error context message:
let user = ctx.
._else?;
// or discard original error:
let user = ctx.
._else?;
assert boolean condition
._else
log config
DB config
let config = Config ;
use sqlx
let user = .bind
.fetch_one
.await?; // `Response` implements `From<sqlx::Error>`
tests
- split server-setup and running:
- write tests using
assert_to_res,assert_not_to_res:
Development
ohkami is on very early stage now and not for producntion use.
License
This project is under MIT LICENSE (LICENSE-MIT or https://opensource.org/licenses/MIT).