upgrade to async rocket
This commit is contained in:
parent
0bf7192ac0
commit
40c147e9c1
File diff suppressed because it is too large
Load Diff
|
@ -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"]
|
||||
|
|
23
src/main.rs
23
src/main.rs
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue