#iron #http #http-header #hyper #rest

nightly austenite

一个用于构建 Iron 处理器的库,实现了 HTTP 报头处理和内容协商

1 个不稳定版本

使用旧的 Rust 2015

0.0.1 2015 年 2 月 9 日

#74 in #iron

64KB
1.5K SLoC

Austenite

Austenite 是一个用于构建 Iron 处理器的库,实现了 HTTP 报头处理和内容协商。

Austenite 是 Clojure 的 Liberator 库的移植,该库本身受到 Erlang 的 webmachine 的启发。

安装

austenite = "*" 添加到您的 Cargo.toml 依赖项中。

用法

struct GetOkContent;
resource_handler!(GetOkContent);

impl Resource for GetOkContent {
    fn handle_ok(&self, req: &Request, resp: &mut Response)
               -> IronResult<Response>
    {
      resp.set_mut((status::Ok, "hello"));
      Ok(Response::new())
    }
}Iron::new(Resource).listen((address,0u16));

许可证

待定


lib.rs:

Austenite

Austenite 是一个用于构建 Iron 处理器的库,实现了 HTTP 报头处理和内容协商。

#[macro_use] extern crate austenite;
use austenite::handle;
use iron::{Iron, Listening, Request, Response};

struct GetOkContent;
resource_handler!(GetOkContent);
impl Resource for GetOkContent {
    fn handle_ok(&self, req: &Request, resp: &mut Response)
               -> IronResult<Response>
    {
      resp.set_mut((status::Ok, "hello"));
      Ok(Response::new())
    }
}

fn start_iron() -> Listening {
  Iron::new(Resource).listen((address,0u16)).unwrap();
}

依赖项

~9MB
~153K SLoC