upgrade to async rocket

This commit is contained in:
mycognosist 2021-10-30 15:12:44 +02:00
parent 0bf7192ac0
commit 40c147e9c1
3 changed files with 1110 additions and 608 deletions

1687
Cargo.lock generated

File diff suppressed because it is too large Load Diff

View File

@ -9,14 +9,10 @@ edition = "2018"
[dependencies]
log = "0.4"
regex = "1"
rocket = "0.4"
rocket = { version = "0.5.0-rc.1", features = ["json"] }
rocket_dyn_templates = { version = "0.1.0-rc.1", features = ["tera"] }
rss = "1"
serde = "1"
serde_derive = "1"
serde_json = "1"
tera = "1"
[dependencies.rocket_contrib]
version = "0.4"
default-features = false
features = ["json", "tera_templates"]

View File

@ -1,18 +1,17 @@
#![feature(proc_macro_hygiene, decl_macro)]
#[macro_use]
extern crate log;
#[macro_use]
extern crate rocket;
extern crate rocket_contrib;
#[macro_use]
extern crate serde_derive;
extern crate tera;
use std::path::{Path, PathBuf};
use rocket::response::NamedFile;
use rocket_contrib::templates::Template;
use rocket::{
fs::{relative, FileServer},
get, routes,
};
use rocket_dyn_templates::Template;
#[derive(Debug, Serialize)]
struct FlashContext {
@ -20,10 +19,12 @@ struct FlashContext {
flash_msg: Option<String>,
}
/*
#[get("/<file..>")]
fn files(file: PathBuf) -> Option<NamedFile> {
NamedFile::open(Path::new("static/").join(file)).ok()
}
*/
#[get("/art")]
fn art() -> Template {
@ -287,12 +288,12 @@ fn not_found() -> Template {
Template::render("not_found", context)
}
fn main() {
rocket::ignite()
#[launch]
fn rocket() -> _ {
rocket::build()
.mount(
"/",
routes![
files,
art,
background,
bacteria,
@ -323,7 +324,7 @@ fn main() {
support
],
)
.register(catchers![not_found])
.mount("/", FileServer::from(relative!("static")))
.register("/", catchers![not_found])
.attach(Template::fairing())
.launch();
}