A Rust Webserver Interface
Inspired by Rack.
Currently tracks Rust nightlies.
$ git clone git://github.com/passcod/rast
$ cd rast
$ rustc rast.rs
extern crate rast;
extern crate server;
mod your_own;
mod another;
fn main() {
let it = rast::Stack::new(&server::Handler { port: 8080 });
it.uses(your_own::Middleware { auth: "secret" });
it.uses(your_own::Application { });
it.uses(another::Middleware { gzip: true });
it.starts();
}
See handlers/rast_http.rs for a working implementation. Generally:
- You need to
extern crate
bothrast
,url
, and the server library. - You need to
use std::collections::HashMap;
. - You need to define a
struct SomeServerHandler { ... }
. Usually that will contain the configuration for the server. - You need to implement rast::Server for that struct.
See examples/hello-app.rs for a working example. Generally:
- You need to
extern crate
bothrast
andurl
. - You need to
use std::collections::HashMap;
. - You need to create a
struct SomeApp;
. - You need to implement rast::App for that struct.
- Inspired from Rack.
- As well as rust-http.
- Public Domain.