An asynchronous, multi-threaded and minimal web framework for Rust.
Asynchronous. In arc reactor, route handlers are asynchronous by default.
Integration With futures-await. The #[service]
proc macro not only derives the ArcService
trait for your route handler, but also marks it as #[async]
so you can await on futures in your route handlers with no extra stress.
Intuitive Middleware System. arc reactor exposes a middleware system that is easy to reason about.
Minimalistic. arc reactor is designed to be a very thin abstraction over tokio and hyper.
Nightly Rust. arc reactor uses a lot of cool features, including proc_macros
which are only available on the nightly channel.
Add this to your cargo.toml
toml
arc-reactor = "0.1"
```rust
extern crate arc_reactor;
extern crate serdejson; use arcreactor::prelude::*; use arc_reactor::{Router, ArcReactor, StatusCode};
fn main() { ArcReactor::new() .routes(rootRoutes()) .port(3000) .initiate() .unwrap() }
fn rootRoutes() -> Router { Router::new() .get("/", IndexRoute) }
fn IndexRoute(_req: Rrequest, res: Response) { let isAuth = await!(fakeFuture()); if isAuth { let payload = json!({ "data": "hello world" });
return Ok(payload.into()) // convert json to json response.
}
res.with_status(StatusCode::UnAuthorized) }
fn fakeFuture() -> impl Future ``` Check out the examples folder and the api documentation to get a feel for how If you feel something is missing, feel free to submit a PR. Refer to License.Examples
arc reactor
works.
It's well documented and should get you up and running in no time.Contributions
License