upgrade to async rocket
This commit is contained in:
parent
0bf7192ac0
commit
40c147e9c1
1687
Cargo.lock
generated
1687
Cargo.lock
generated
File diff suppressed because it is too large
Load Diff
@ -9,14 +9,10 @@ edition = "2018"
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
regex = "1"
|
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"
|
rss = "1"
|
||||||
serde = "1"
|
serde = "1"
|
||||||
serde_derive = "1"
|
serde_derive = "1"
|
||||||
serde_json = "1"
|
serde_json = "1"
|
||||||
tera = "1"
|
tera = "1"
|
||||||
|
|
||||||
[dependencies.rocket_contrib]
|
|
||||||
version = "0.4"
|
|
||||||
default-features = false
|
|
||||||
features = ["json", "tera_templates"]
|
|
||||||
|
23
src/main.rs
23
src/main.rs
@ -1,18 +1,17 @@
|
|||||||
#![feature(proc_macro_hygiene, decl_macro)]
|
#![feature(proc_macro_hygiene, decl_macro)]
|
||||||
|
|
||||||
#[macro_use]
|
|
||||||
extern crate log;
|
extern crate log;
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate rocket;
|
extern crate rocket;
|
||||||
extern crate rocket_contrib;
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate serde_derive;
|
extern crate serde_derive;
|
||||||
extern crate tera;
|
extern crate tera;
|
||||||
|
|
||||||
use std::path::{Path, PathBuf};
|
use rocket::{
|
||||||
|
fs::{relative, FileServer},
|
||||||
use rocket::response::NamedFile;
|
get, routes,
|
||||||
use rocket_contrib::templates::Template;
|
};
|
||||||
|
use rocket_dyn_templates::Template;
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
struct FlashContext {
|
struct FlashContext {
|
||||||
@ -20,10 +19,12 @@ struct FlashContext {
|
|||||||
flash_msg: Option<String>,
|
flash_msg: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
#[get("/<file..>")]
|
#[get("/<file..>")]
|
||||||
fn files(file: PathBuf) -> Option<NamedFile> {
|
fn files(file: PathBuf) -> Option<NamedFile> {
|
||||||
NamedFile::open(Path::new("static/").join(file)).ok()
|
NamedFile::open(Path::new("static/").join(file)).ok()
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
|
||||||
#[get("/art")]
|
#[get("/art")]
|
||||||
fn art() -> Template {
|
fn art() -> Template {
|
||||||
@ -287,12 +288,12 @@ fn not_found() -> Template {
|
|||||||
Template::render("not_found", context)
|
Template::render("not_found", context)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
#[launch]
|
||||||
rocket::ignite()
|
fn rocket() -> _ {
|
||||||
|
rocket::build()
|
||||||
.mount(
|
.mount(
|
||||||
"/",
|
"/",
|
||||||
routes![
|
routes![
|
||||||
files,
|
|
||||||
art,
|
art,
|
||||||
background,
|
background,
|
||||||
bacteria,
|
bacteria,
|
||||||
@ -323,7 +324,7 @@ fn main() {
|
|||||||
support
|
support
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
.register(catchers![not_found])
|
.mount("/", FileServer::from(relative!("static")))
|
||||||
|
.register("/", catchers![not_found])
|
||||||
.attach(Template::fairing())
|
.attach(Template::fairing())
|
||||||
.launch();
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user