From f9e17ce7dfeccad0733726bc177f087481a18031 Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Tue, 4 Oct 2016 15:02:58 -0700 Subject: [PATCH] Update docs for latest changes. --- docs/intro.md | 45 ++++++++++++++++++--------------------------- docs/overview.md | 15 +++++++++------ 2 files changed, 27 insertions(+), 33 deletions(-) diff --git a/docs/intro.md b/docs/intro.md index ed081ce5..e16f020d 100644 --- a/docs/intro.md +++ b/docs/intro.md @@ -131,7 +131,6 @@ program, which we reproduce below: #![plugin(rocket_codegen)] extern crate rocket; -use rocket::Rocket; #[get("/")] fn hello() -> &'static str { @@ -139,7 +138,7 @@ fn hello() -> &'static str { } fn main() { - Rocket::mount_and_launch("/hello", routes![hello]); + rocket::ignite().mount("/hello", routes![hello]).launch(); } ``` @@ -147,6 +146,10 @@ Run the program by using `cargo run`. You should see the following in your terminal: ```sh +πŸ”§ Configured for development. + => listening: localhost:8000 + => logging: Normal + => session key: false πŸ›° Mounting '/hello': => GET /hello/ πŸš€ Rocket has launched from localhost:8000... @@ -155,8 +158,6 @@ terminal: Finally, visit `http://localhost:8000` to see your first Rocket application in action. -## "Hello, world!" Explained - # Introduction Rocket provides a focused number of core primitives to build web servers and @@ -186,7 +187,6 @@ simple application. Let's begin. #![plugin(rocket_codegen)] extern crate rocket; -use rocket::Rocket; #[get("hi//")] fn hello(name: &str, age: i8) -> String { @@ -204,9 +204,10 @@ fn not_found() -> &'static str { } fn main() { - Rocket::ignite().mount("/", routes![hello, goodbye]) - .catch(errors![not_found]) - .launch(); + rocket::ignite() + .mount("/", routes![hello, goodbye]) + .catch(errors![not_found]) + .launch(); } ``` @@ -239,23 +240,13 @@ request is of type `&'static str` whose value is `Hello, world!`. Rocket route attributes have the following grammar: -```python -METHOD '(' PATH?, ('path' = PATH)? ('rank' = INT)? ('form' = STR)? ('format' = STR)? ')' +```ebnf +route := METHOD '(' path, kv_param* ')' + +path := PATH + | 'path' = PATH + +kv_param := 'rank' = INTEGER + | 'form' = STRING + | 'format' = STRING ``` - -## Outline - -* Request/Response Cycle -* Routes and Handlers -* Mounting -* Dynamic Parameters -* Path Parameters -* Colliding and Ranks -* FromParam -* FromSegments -* FromRequest -* Responses -* Responder -* Contrib -* JSON -* Templates diff --git a/docs/overview.md b/docs/overview.md index 2f70ddb5..be85b4f1 100644 --- a/docs/overview.md +++ b/docs/overview.md @@ -18,7 +18,6 @@ examples in [Rocket's git repository](github). Can you figure out what it does? #![plugin(rocket_codegen)] extern crate rocket; -use rocket::Rocket; #[get("//")] fn hello(name: &str, age: u8) -> String { @@ -26,15 +25,19 @@ fn hello(name: &str, age: u8) -> String { } fn main() { - let mut rocket = Rocket::ignite(); - rocket.mount("/hello", routes![hello]); - rocket.launch() + rocket::ignite() + .mount("/hello", routes![hello]) + .launch(); } ``` If you were to run this application, your console would show: ```sh +πŸ”§ Configured for development. + => listening: localhost:8000 + => logging: Normal + => session key: false πŸ›° Mounting '/hello': => GET /hello// πŸš€ Rocket has launched from localhost:8000... @@ -135,8 +138,8 @@ about the `route!` macro, see the [internals guide](guide/internals). Let's look at lines 13 - 14 again, which we reproduce below: ```rust -let mut rocket = Rocket::ignite(); -rocket.mount(β€œ/hello”, routes![hello]); +rocket::ignite() + .mount(β€œ/hello”, routes![hello]) ``` Line 13 creates the new `Rocket` instance, and line 14 mounts the `hello` route