A web framework for Rust.
Go to file
Sergio Benitez 26b7b814f4 Progress on errors. Started Todo example.
The error function now takes in a "RoutingError" structure. The idea is that the
structure includes all of the information necessary for a user to processor the
error as they wish. This interface is very incomplete and may change. At a
minimum, the error structure should include:

  1) The request that failed.
  2) Why the request failed.
  3) The chain of attempted route matches, if any.
  4) Something else?
2016-07-15 21:09:08 -07:00
docs Initial commit. Checking for method and path arguments in route. Not storing the info anywhere yet. 2016-03-07 11:28:04 -08:00
examples Progress on errors. Started Todo example. 2016-07-15 21:09:08 -07:00
lib Progress on errors. Started Todo example. 2016-07-15 21:09:08 -07:00
macros Progress on errors. Started Todo example. 2016-07-15 21:09:08 -07:00
scripts Fixed all valid Clippy warnings. Removed deprecated method call. 2016-04-22 19:48:03 -07:00
.gitignore Rocket is almost operational! `routes!` macro complete. 2016-03-12 10:45:19 -08:00
.travis.yml Added a travis file. 2016-03-17 20:18:16 -07:00
README.md Working error handling! Not quite there yet though. 2016-04-06 13:50:02 -07:00

README.md

Rocket

Build Status

Rocket is a work-in-progress web framework for Rust (nightly) with a focus on ease-of-use, expressability, and speed. Here's an example of a complete Rocket application:

#![feature(plugin)]
#![plugin(rocket_macros)]

extern crate rocket;
use rocket::Rocket;

#[route(GET, path = "/<name>/<age>")]
fn hello(name: &str, age: u8) -> String {
    format!("Hello, {} year old named {}!", age, name)
}

fn main() {
    Rocket::new("localhost", 8000).mount_and_launch("/hello", routes![hello]);
}

Visiting localhost:8000/hello/John/58, for example, will trigger the hello route resulting in the string Hello, 58 year old named John! being sent to the browser. If an <age> string was passed in that can't be parsed as a u8, the route won't get called, resulting in a 404 error.

Rocket requires a nightly version of Rust as it makes heavy use of syntax extensions. This also means that the first two unwieldly lines in the Rust file above are required.

Building

Try running the examples in the examples/ folder. For instance, the following sequence of commands builds and runs the Hello, world! example:

cd examples/hello_world
cargo run

Then visit localhost:8000. You should see Hello, world!.

OS X

Apple has stopped shipping openssl with OS X.11. As such, if your build fails to compile with some openssl related errors, you'll need to install openssl, cargo clean, and then cargo build again. Here are some lightweight instructions:

brew install openssl
brew link --force openssl
export OPENSSL_INCLUDE_DIR=`brew --prefix openssl`/include
export OPENSSL_LIB_DIR=`brew --prefix openssl`/lib