This repository contains a sample that I used to do an introduction talk about Building Web APIs with Rust and Rocket at the Rust Linz meetup.
cargo new rusty-rocket-live
code .
cp -R ../rusty-rocket/.vscode ./.vscode
- Open Cargo.toml
- Snippet 010-rocket-dependency in
[dependencies]
- Snippet 015-rocket-git
cargo build
- Open main.rs
- Snippet 020-use, fold region
- Snippet 025-basic-get and 030-basic-launch
cp -R ../rusty-rocket/requests.http .
- Demo request
- Create src/tests.rs
- Snippet 040-basic-test in tests.rs
- Snippet 035-annotate-test-module in main.rs
cargo test
- Snippet 045-dynamic-path in main.rs
- Add
greeting
to mounts - Demo request
- Snippet 050-dynamic-path-test in test.rs
cargo test
- Snippet 055-query-string-params in main.rs
- Add
query_greeting
to mounts - Demo request
- Snippet 060-query-string-tests in test.rs
cargo test
- Create src/api_key.rs
- Snippet 065-custom-request-guard in api-key.rs
- Snippet 070-route-with-guard in main.rs
- Add
protected
to mounts - Demo request
- Snippet 075-tests-guarded-route in test.rs
cargo test
- Snippet 080-cookie-guard in main.rs
- Add
login
andsession
to mounts - Demo request
- Snippet 085-cookie-test in test.rs
cargo test
- Snippet 090-hero-api-region
- Inside:
- Snippet 100-hero-api-structs-types
- Snippet 105-in-memory-repository
- Snippet 110-add-hero-with-post
- Snippet 115-get-single-hero
- Snippet 120-get-all-heroes
- Add
add_hero
,get_hero
, andget_all
to mounts - At the end: Snippet 111-add-managed-hashmap
- Demo request
- Snippet 125-404-catcher
- Snippet 126-register-catcher
- Demo request
- Snippet 130-log-fairing
- Snippet 135-attach-fairing
- Demo request
- Show Seq