Created
May 22, 2021 18:43
-
-
Save mhutter/98d77c21ad352cdaa92039bd6e3981a8 to your computer and use it in GitHub Desktop.
Rust Rocket examples
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(proc_macro_hygiene, decl_macro)] | |
use rocket::State; | |
#[macro_use] | |
extern crate rocket; | |
struct ExampleA(&'static str); | |
type ExampleB = &'static str; | |
#[get("/a")] | |
fn a(a: State<ExampleA>) -> &'static str { | |
a.0 | |
} | |
#[get("/b")] | |
fn b(b: State<ExampleB>) -> &'static str { | |
b.inner() | |
} | |
fn main() { | |
rocket::ignite() | |
.mount("/", routes![a, b]) | |
.manage(ExampleA("some config")) | |
.manage("v1.3.37" as ExampleB) | |
.launch(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment