Tsukuyomi is a next generation Web framework for Rust.
The ultimate goal of this project is to provide a Web framework for developing the asynchronous and fast Web services, with the help of ecosystem of Rust for asynchronous network services like Tokio and Hyper.
rustls
The following features does not currently implemented but will be supported in the future version:
Tsukuyomi requires the latest version of Rust compiler. The required Rust toolchain is 1.27 or higher.
toml
[dependencies]
tsukuyomi = "0.2"
futures = "0.1.22"
```rust,no_run extern crate tsukuyomi; extern crate futures;
use tsukuyomi::{App, Input, Error, Handler}; use futures::Future;
// A synchronous handler function.
// It will return a Responder
which immediately convert into an HTTP response,
// and does not need any asynchronous computation.
fn handler(_input: &mut Input) -> &'static str {
"Hello, Tsukuyomi.\n"
}
// An asynchronous handler function.
// It will return a Future
representing the remaining computation in the handler.
fn asynchandler(input: &mut Input)
-> impl FutureInput
stored in
// the task-local storage by using Input::withcurrent():
Input::withcurrent(|input| {
println!("[debug] path = {}", input.uri().path());
})
})
}
fn main() -> tsukuyomi::AppResult<()> { let app = App::builder() .mount("/", |m| { m.get("/") .handle(Handler::new_ready(handler));
m.post("/async")
.handle(Handler::new_async(async_handler));
})
.finish()?;
tsukuyomi::run(app)
} ```
futures-await
(requires Nightly compiler)toml
[dependencies]
tsukuyomi = "0.2"
futures-await = "0.1"
```rust,no_run
extern crate tsukuyomi; extern crate futures_await as futures;
use futures::prelude::{async, await, Future}; use tsukuyomi::{App, Input, Handler};
fn handler() -> tsukuyomi::Result
fn main() -> tsukuyomi::AppResult<()> { let app = App::builder() .mount("/", |m| { m.post("/") .handle(Handler::newfullyasync(handler)); }) .finish()?;
tsukuyomi::run(app)
} ```
More examples are located in examples/
.
If you want to experiment with these examples, try to clone this repository and run the following command:
shell-session
$ cargo run -p example-basic
| Travis CI | Appveor | Coveralls |
|:---------:|:-------:|:---------:|
| |
|
|
Tsukuyomi is licensed under either of MIT license or Apache License, Version 2.0 at your option.