diff --git a/README.md b/README.md index 852c3f3..4c64c08 100644 --- a/README.md +++ b/README.md @@ -55,7 +55,7 @@ fn main() { rocket_csrf::CsrfConfig::default() .with_cookie_name("foobar") .with_cookie_len(64) - .with_lifetime(time::Duration::days(3)) + .with_lifetime(time::Duration::days(3)), )) .attach(Template::fairing()) .mount("/", routes![new, create]) diff --git a/examples/minimal/src/main.rs b/examples/minimal/src/main.rs index 7cc2ce0..fb8bd06 100644 --- a/examples/minimal/src/main.rs +++ b/examples/minimal/src/main.rs @@ -1,10 +1,12 @@ #![feature(decl_macro)] -#[macro_use] extern crate rocket; -#[macro_use] extern crate serde_derive; +#[macro_use] +extern crate rocket; +#[macro_use] +extern crate serde_derive; -use rocket::response::{Flash, Redirect}; use rocket::request::{FlashMessage, Form}; +use rocket::response::{Flash, Redirect}; use rocket_contrib::templates::Template; use rocket_csrf::CsrfToken; @@ -46,10 +48,7 @@ fn new(csrf_token: CsrfToken, flash: Option) -> Template { #[post("/comments", data = "
")] fn create(csrf_token: CsrfToken, form: Form) -> Flash { if let Err(_) = csrf_token.verify(&form.authenticity_token) { - return Flash::error( - Redirect::to(uri!(new)), - "invalid authenticity token", - ); + return Flash::error(Redirect::to(uri!(new)), "invalid authenticity token"); } Flash::success( diff --git a/tests/fairing_configured.rs b/tests/fairing_configured.rs index c1b3544..a7b4a5a 100644 --- a/tests/fairing_configured.rs +++ b/tests/fairing_configured.rs @@ -1,6 +1,7 @@ #![feature(decl_macro)] -#[macro_use] extern crate rocket; +#[macro_use] +extern crate rocket; const COOKIE_NAME: &str = "foobar"; const COOKIE_LEN: usize = 64; @@ -15,18 +16,25 @@ fn rocket() -> rocket::Rocket { rocket_csrf::CsrfConfig::default() .with_cookie_name(COOKIE_NAME) .with_cookie_len(COOKIE_LEN) - .with_lifetime(time::Duration::days(3)) + .with_lifetime(time::Duration::days(3)), )) .mount("/", routes![index]) } #[get("/")] -fn index() { -} +fn index() {} #[test] fn add_csrf_token_to_cookies() { - base64::decode(client().get("/").dispatch().cookies().iter().find(|cookie| { - cookie.name() == COOKIE_NAME - }).unwrap().value()).unwrap(); + base64::decode( + client() + .get("/") + .dispatch() + .cookies() + .iter() + .find(|cookie| cookie.name() == COOKIE_NAME) + .unwrap() + .value(), + ) + .unwrap(); } diff --git a/tests/fairing_default.rs b/tests/fairing_default.rs index 87e6a8c..00d7d8a 100644 --- a/tests/fairing_default.rs +++ b/tests/fairing_default.rs @@ -1,6 +1,7 @@ #![feature(decl_macro)] -#[macro_use] extern crate rocket; +#[macro_use] +extern crate rocket; fn client() -> rocket::local::Client { rocket::local::Client::new(rocket()).unwrap() @@ -13,12 +14,19 @@ fn rocket() -> rocket::Rocket { } #[get("/")] -fn index() { -} +fn index() {} #[test] fn add_csrf_token_to_cookies() { - base64::decode(client().get("/").dispatch().cookies().iter().find(|cookie| { - cookie.name() == "csrf_token" - }).unwrap().value()).unwrap(); + base64::decode( + client() + .get("/") + .dispatch() + .cookies() + .iter() + .find(|cookie| cookie.name() == "csrf_token") + .unwrap() + .value(), + ) + .unwrap(); } diff --git a/tests/guard_configured.rs b/tests/guard_configured.rs index bae0b11..89c31ee 100644 --- a/tests/guard_configured.rs +++ b/tests/guard_configured.rs @@ -1,11 +1,12 @@ #![feature(decl_macro)] -#[macro_use] extern crate rocket; +#[macro_use] +extern crate rocket; +use bcrypt::verify; use rand::RngCore; use rocket::http::Cookie; use rocket_csrf::CsrfToken; -use bcrypt::verify; const COOKIE_NAME: &str = "foobar"; const COOKIE_LEN: usize = 64; @@ -20,7 +21,7 @@ fn rocket() -> rocket::Rocket { rocket_csrf::CsrfConfig::default() .with_cookie_name(COOKIE_NAME) .with_cookie_len(COOKIE_LEN) - .with_lifetime(time::Duration::days(3)) + .with_lifetime(time::Duration::days(3)), )) .mount("/", routes![index]) } diff --git a/tests/guard_default.rs b/tests/guard_default.rs index 1f696b3..af80a29 100644 --- a/tests/guard_default.rs +++ b/tests/guard_default.rs @@ -1,11 +1,12 @@ #![feature(decl_macro)] -#[macro_use] extern crate rocket; +#[macro_use] +extern crate rocket; +use bcrypt::verify; use rand::RngCore; use rocket::http::Cookie; use rocket_csrf::CsrfToken; -use bcrypt::verify; fn client() -> rocket::local::Client { rocket::local::Client::new(rocket()).unwrap()