Last active
November 18, 2018 19:07
-
-
Save xorl/4ab5e53746c3f14522856bd5d3f41f4b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#![feature(plugin, custom_derive)] | |
#![feature(proc_macro_hygiene, decl_macro)] | |
extern crate bloglib; | |
#[macro_use] extern crate rocket; | |
extern crate rocket_contrib; | |
extern crate rsass; | |
use bloglib::*; | |
use bloglib::{auth, posts}; | |
use rocket::{Catcher, Request}; | |
use rocket_contrib::templates::Template; | |
use rocket::response::{Redirect, Responder, Result}; | |
use rsass::{OutputStyle, compile_scss_file}; | |
#[catch(400)] | |
fn redirect_login<'r>(req: &'r Request) -> Result<'r> { | |
Redirect::to("/auth/login").respond_to(req) | |
} | |
#[catch(401)] | |
fn redirect_root<'r>(req: &'r Request) -> Result<'r> { | |
Redirect::to("/").respond_to(req) | |
} | |
#[catch(500)] | |
fn handle_500<'r>(req: &'r Request) -> Result<'r> { | |
"Whoops, we messed up!".respond_to(req) | |
} | |
fn main() { | |
let login = Catcher::new(600, redirect_login); | |
let root = Catcher::new(601, redirect_root); | |
let ise = Catcher::new(500, handle_500); | |
// Build that SCSS | |
let cssfile = "assets/stylesheets/base.scss".as_ref(); | |
let css = compile_scss_file(cssfile, OutputStyle::Compressed).unwrap(); | |
println!("format {:?} arguments", css); | |
rocket::ignite() | |
.manage(create_db_pool()) | |
.mount("/", posts::routes()) | |
.mount("/auth", auth::routes()) | |
.attach(Template::fairing()) | |
.register(catchers![login, root, ise]) | |
.launch(); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
error[E0425]: cannot find value `static_rocket_catch_info_for_login` in this scope | |
--> src/bin/main.rs:48:29 | |
| | |
48 | .register(catchers![login, root, ise]) | |
| ^^^^^ did you mean `static_rocket_catch_info_for_handle_500`? | |
error[E0425]: cannot find value `static_rocket_catch_info_for_root` in this scope | |
--> src/bin/main.rs:48:36 | |
| | |
48 | .register(catchers![login, root, ise]) | |
| ^^^^ did you mean `static_rocket_catch_info_for_redirect_root`? | |
error[E0425]: cannot find value `static_rocket_catch_info_for_ise` in this scope | |
--> src/bin/main.rs:48:42 | |
| | |
48 | .register(catchers![login, root, ise]) | |
| ^^^ did you mean `static_rocket_catch_info_for_handle_500`? | |
error[E0308]: mismatched types | |
--> src/bin/main.rs:19:23 | |
| | |
19 | fn redirect_login<'r>(req: &'r Request) -> Result<'r> { | |
| ^^^^^^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter | |
| | |
= note: expected type `for<'r, 's> fn(&'r rocket::Request<'s>) -> _` | |
found type `for<'r, 's> fn(&'r rocket::Request<'s>) -> std::result::Result<rocket::Response<'r>, rocket::http::Status> {redirect_login}` | |
error[E0308]: mismatched types | |
--> src/bin/main.rs:24:22 | |
| | |
24 | fn redirect_root<'r>(req: &'r Request) -> Result<'r> { | |
| ^^^^^^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter | |
| | |
= note: expected type `for<'r, 's> fn(&'r rocket::Request<'s>) -> _` | |
found type `for<'r, 's> fn(&'r rocket::Request<'s>) -> std::result::Result<rocket::Response<'r>, rocket::http::Status> {redirect_root}` | |
error[E0308]: mismatched types | |
--> src/bin/main.rs:29:19 | |
| | |
29 | fn handle_500<'r>(req: &'r Request) -> Result<'r> { | |
| ^^^^^^^^^^^^^^^^ expected concrete lifetime, found bound lifetime parameter | |
| | |
= note: expected type `for<'r, 's> fn(&'r rocket::Request<'s>) -> _` | |
found type `for<'r, 's> fn(&'r rocket::Request<'s>) -> std::result::Result<rocket::Response<'r>, rocket::http::Status> {handle_500}` | |
error: aborting due to 6 previous errors | |
Some errors occurred: E0308, E0425. | |
For more information about an error, try `rustc --explain E0308`. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment