Rocket

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

commit 1c496b3424155745832bbb335be386b859235ffb
parent a2ada8498603a80f38e1d8c5ee3a6c6841730771
Author: Sergio Benitez <sb@sergio.bz>
Date:   Tue,  6 Nov 2018 23:35:03 -0800

Improve the overview site page.

Diffstat:
Msite/overview.toml | 6+++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/site/overview.toml b/site/overview.toml @@ -34,7 +34,7 @@ illustrate, let's use the following route: ```rust #[get("/hello/<name>/<age>")] -fn hello(name: &str, age: u8) -> String { +fn hello(name: String, age: u8) -> String { format!("Hello, {} year old named {}!", age, name) } ``` @@ -92,12 +92,12 @@ header, Rocket can protect those calls via a custom `ApiKey` request guard: ```rust #[get("/sensitive")] -fn sensitive(key: ApiKey) -> &'static str { ... } +fn sensitive(key: ApiKey) { ... } ``` `ApiKey` protects the `sensitive` handler from running incorrectly. In order for Rocket to call the `sensitive` handler, the `ApiKey` type needs to be derived -through a [FromRequest](@api/rocket/request/trait.FromRequest.html) +through a [`FromRequest`](@api/rocket/request/trait.FromRequest.html) implementation, which in this case, validates the API key header. Request guards are a powerful and unique Rocket concept; they centralize application policy and invariants through types.