arc-reactor 0.1.5

Minimal, Asynchronous, Web Framework
docs.rs failed to build arc-reactor-0.1.5
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build: arc-reactor-0.2.4

Arc-reactor

Arc Reactor An asynchronous, multi-threaded and minimal web framework for Rust.

Crates.io

Features

  • 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.

  • TLS Support. easy to add tls support.

  • Nightly Rust. arc reactor uses a lot of cool features, including proc_macros which are only available on the nightly channel.

Installation

Add this to your cargo.toml

arc-reactor = "0.1"

Demo

#![feature(conservative_impl_trait, proc_macro, generators, box_syntax)] // <== need to add this.
extern crate arc_reactor;
#[macro_use]
extern crate serde_json;
use arc_reactor::prelude::*;
use arc_reactor::{Router, ArcReactor, StatusCode};

fn main() {
  ArcReactor::new()
    .routes(rootRoutes())
     .port(3000)
     .initiate()
     .unwrap()
}

fn rootRoutes() -> Router {
  Router::new()
    .get("/", IndexRoute)
}


#[service]
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<Item=bool, Error=()> {
  futures::future::ok(true)
}

Examples

Check out the examples folder and the api documentation to get a feel for how arc reactor works. It's well documented and should get you up and running in no time.

Contributions

If you feel something is missing, feel free to submit a PR.

License

Refer to License.