1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-06-26 10:27:42 +02:00
This commit is contained in:
Rob Ede
2023-01-07 01:04:16 +00:00
parent 6848312467
commit 779860b664
13 changed files with 27 additions and 29 deletions

View File

@ -3,11 +3,11 @@ use actix_web::{cookie::Key, middleware, web, App, Error, HttpRequest, HttpServe
/// simple handler
async fn index(req: HttpRequest, session: Session) -> Result<impl Responder, Error> {
println!("{:?}", req);
println!("{req:?}");
// session
if let Some(count) = session.get::<i32>("counter")? {
println!("SESSION value: {}", count);
println!("SESSION value: {count}");
session.insert("counter", count + 1)?;
} else {
session.insert("counter", 1)?;

View File

@ -179,7 +179,7 @@ pub mod test_helpers {
CookieContentSecurity::Signed,
CookieContentSecurity::Private,
] {
println!("Using {:?} as cookie content security policy.", policy);
println!("Using {policy:?} as cookie content security policy.");
acceptance_tests::basic_workflow(store_builder.clone(), *policy).await;
acceptance_tests::expiration_is_refreshed_on_changes(store_builder.clone(), *policy)
.await;
@ -243,7 +243,7 @@ pub mod test_helpers {
}))
.service(web::resource("/test/").to(|ses: Session| async move {
let val: usize = ses.get("counter").unwrap().unwrap();
format!("counter: {}", val)
format!("counter: {val}")
})),
)
.await;
@ -710,9 +710,9 @@ pub mod test_helpers {
async fn logout(session: Session) -> Result<HttpResponse> {
let id: Option<String> = session.get("user_id")?;
let body = if let Some(x) = id {
let body = if let Some(id) = id {
session.purge();
format!("Logged out: {}", x)
format!("Logged out: {id}")
} else {
"Could not log out anonymous user".to_owned()
};

View File

@ -291,7 +291,7 @@ impl FromRequest for Session {
/// Error returned by [`Session::get`].
#[derive(Debug, Display, From)]
#[display(fmt = "{}", _0)]
#[display(fmt = "{_0}")]
pub struct SessionGetError(anyhow::Error);
impl StdError for SessionGetError {
@ -308,7 +308,7 @@ impl ResponseError for SessionGetError {
/// Error returned by [`Session::insert`].
#[derive(Debug, Display, From)]
#[display(fmt = "{}", _0)]
#[display(fmt = "{_0}")]
pub struct SessionInsertError(anyhow::Error);
impl StdError for SessionInsertError {