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

38 lines
724 B
Rust
Raw Normal View History

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