Crates.io | amiya |
lib.rs | amiya |
version | 0.0.6 |
source | src |
created_at | 2020-07-20 19:12:41.576837 |
updated_at | 2021-03-27 15:01:00.234916 |
description | experimental middleware-based minimalism async HTTP server framework |
homepage | https://github.com/7sDream/amiya |
repository | https://github.com/7sDream/amiya |
max_upload_size | |
id | 267349 |
size | 102,411 |
Amiya is a experimental middleware-based minimalism async HTTP server framework,
built up on smol-rs
related asynchronous components.
It's currently still working in progress and in a very early alpha stage.
API design may changes, DO NOT use it in any condition except for test or study!
The goal of this project is try to build a (by importance order):
#![forbid(unsafe_code)]
HTTP framework for myself to write simple web services.
Amiya uses async-h1
to parse and process requests, so only HTTP version 1.1 is supported for
now. HTTP 1.0 or 2.0 is not in goal list, at least in the near future.
Performance is NOT in the list too, after all, Amiya is just a experimental for now, it uses
many heap alloc (Box) and dynamic dispatch (Trait Object) so there may be some performance loss
compare to use async-h1
directly.
To start a very simple HTTP service that returns Hello World
to the client in all paths:
use amiya::m;
fn main() {
let app = amiya::new().uses(m!(ctx =>
ctx.resp.set_body(format!("Hello World from: {}", ctx.path()));
));
app.listen("[::]:8080").unwrap();
// ... do other things you want ...
// ... Amiya server will not block your thread ...
}
Amiya has a built-in multi-thread async executor powered by async-executor
and async-io
, http server will run
in it. So Amiya::listen
is just a normal non-async method, and do not block your thread.
To run examples, run
cargo run --example # show example list
cargo run --example hello # run hello
Top level document of crate has a brief description of concepts used in this framework, I recommend give it a read first, and then check those examples to get a more intuitive understanding:
examples/middleware.rs
examples/measurer.rs
examples/extra.rs
Router
middleware for request diversion: examples/router.rs
examples/query.rs
examples/urlencoded.rs
examples/arg.rs
examples/subapp.rs
listen
returned signal sender: examples/stop.rs
Most of those example will use builtin executor, see example/tokio_executor.rs
for how to use a custom executor with Amiya.
BSD 3-Clause Clear License, See LICENSE
.