1
0
Fork 0
This repository has been archived on 2023-03-27. You can view files and clone it, but cannot push or open issues or pull requests.
fedihub-website/src/main.rs

34 lines
672 B
Rust
Raw Normal View History

2020-10-13 19:40:03 -04:00
#![feature(proc_macro_hygiene, decl_macro)]
#[macro_use] extern crate rocket;
2020-10-13 20:13:00 -04:00
#[macro_use] extern crate serde_derive;
extern crate rocket_contrib;
2020-10-13 19:40:03 -04:00
2020-10-13 20:01:25 -04:00
use rocket_contrib::templates::Template;
2020-10-13 20:13:00 -04:00
#[derive(Serialize)]
struct TemplateContext {
parent: &'static str,
2020-10-13 20:22:37 -04:00
users: Vec<&'static str>,
2020-10-13 20:13:00 -04:00
}
2020-10-13 20:26:03 -04:00
fn main() {
2020-10-13 20:27:00 -04:00
rocket().launch();
}
fn rocket() -> rocket::Rocket {
2020-10-13 20:26:03 -04:00
rocket::ignite()
.attach(Template::fairing())
.mount("/", routes![index])
}
2020-10-13 19:40:03 -04:00
#[get("/")]
2020-10-13 20:01:25 -04:00
fn index() -> Template {
2020-10-13 20:13:00 -04:00
let template_context = TemplateContext {
parent: "layout",
2020-10-13 20:22:37 -04:00
users: vec!["foo", "bar", "car"],
2020-10-13 20:13:00 -04:00
};
Template::render("index", &template_context)
2020-10-13 19:40:03 -04:00
}