Skip to content
This repository has been archived by the owner on Jun 2, 2020. It is now read-only.

passcod/rast

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Rast

A Rust Webserver Interface

Inspired by Rack.

Build

Currently tracks Rust nightlies.

$ git clone git://github.com/passcod/rast
$ cd rast
$ rustc rast.rs

Use

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();
}

Servers

See handlers/rast_http.rs for a working implementation. Generally:

  • You need to extern crate both rast, 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.

Apps (and middleware)

See examples/hello-app.rs for a working example. Generally:

  • You need to extern crate both rast and url.
  • You need to use std::collections::HashMap;.
  • You need to create a struct SomeApp;.
  • You need to implement rast::App for that struct.

Community