mirror of
https://github.com/actix/actix-extras.git
synced 2025-06-26 10:27:42 +02:00
migrate to actix-web beta 14 (#209)
This commit is contained in:
@ -1,6 +1,10 @@
|
||||
# Changes
|
||||
|
||||
## Unreleased - 2021-xx-xx
|
||||
* Update `actix-web` dependency to `4.0.0.beta-14`. [#209]
|
||||
* Remove `UserSession` implementation for `RequestHead`. [#209]
|
||||
|
||||
[#209]: https://github.com/actix/actix-extras/pull/209
|
||||
|
||||
|
||||
## 0.5.0-beta.4 - 2021-11-22
|
||||
|
@ -20,7 +20,7 @@ cookie-session = ["actix-web/secure-cookies"]
|
||||
[dependencies]
|
||||
actix-service = "2.0.0"
|
||||
actix-utils = "3"
|
||||
actix-web = { version = "4.0.0-beta.10", default_features = false, features = ["cookies"] }
|
||||
actix-web = { version = "4.0.0-beta.14", default_features = false, features = ["cookies"] }
|
||||
|
||||
derive_more = "0.99.5"
|
||||
futures-util = { version = "0.3.7", default-features = false }
|
||||
|
@ -4,10 +4,10 @@ use std::{collections::HashMap, error::Error as StdError, rc::Rc};
|
||||
|
||||
use actix_utils::future::{ok, Ready};
|
||||
use actix_web::{
|
||||
body::{AnyBody, MessageBody},
|
||||
body::{EitherBody, MessageBody},
|
||||
cookie::{Cookie, CookieJar, Key, SameSite},
|
||||
dev::{Service, ServiceRequest, ServiceResponse, Transform},
|
||||
http::{header::SET_COOKIE, HeaderValue},
|
||||
http::header::{HeaderValue, SET_COOKIE},
|
||||
Error, ResponseError,
|
||||
};
|
||||
use derive_more::Display;
|
||||
@ -303,7 +303,7 @@ where
|
||||
B: MessageBody + 'static,
|
||||
B::Error: StdError,
|
||||
{
|
||||
type Response = ServiceResponse;
|
||||
type Response = ServiceResponse<EitherBody<B>>;
|
||||
type Error = S::Error;
|
||||
type InitError = ();
|
||||
type Transform = CookieSessionMiddleware<S>;
|
||||
@ -331,7 +331,7 @@ where
|
||||
B: MessageBody + 'static,
|
||||
B::Error: StdError,
|
||||
{
|
||||
type Response = ServiceResponse;
|
||||
type Response = ServiceResponse<EitherBody<B>>;
|
||||
type Error = S::Error;
|
||||
type Future = LocalBoxFuture<'static, Result<Self::Response, Self::Error>>;
|
||||
|
||||
@ -379,8 +379,8 @@ where
|
||||
};
|
||||
|
||||
match result {
|
||||
Ok(()) => Ok(res.map_body(|_, body| AnyBody::new_boxed(body))),
|
||||
Err(error) => Ok(res.error_response(error)),
|
||||
Ok(()) => Ok(res.map_into_left_body()),
|
||||
Err(error) => Ok(res.error_response(error).map_into_right_body()),
|
||||
}
|
||||
}
|
||||
.boxed_local()
|
||||
|
@ -51,7 +51,7 @@ use std::{
|
||||
|
||||
use actix_utils::future::{ok, Ready};
|
||||
use actix_web::{
|
||||
dev::{Extensions, Payload, RequestHead, ServiceRequest, ServiceResponse},
|
||||
dev::{Extensions, Payload, ServiceRequest, ServiceResponse},
|
||||
Error, FromRequest, HttpMessage, HttpRequest,
|
||||
};
|
||||
use serde::{de::DeserializeOwned, Serialize};
|
||||
@ -101,12 +101,6 @@ impl UserSession for ServiceRequest {
|
||||
}
|
||||
}
|
||||
|
||||
impl UserSession for RequestHead {
|
||||
fn get_session(&self) -> Session {
|
||||
Session::get_session(&mut *self.extensions_mut())
|
||||
}
|
||||
}
|
||||
|
||||
/// Status of a [`Session`].
|
||||
#[derive(PartialEq, Clone, Debug)]
|
||||
pub enum SessionStatus {
|
||||
@ -355,20 +349,6 @@ mod tests {
|
||||
assert_eq!(res, Some(true));
|
||||
}
|
||||
|
||||
#[actix_web::test]
|
||||
async fn get_session_from_request_head() {
|
||||
let mut req = test::TestRequest::default().to_srv_request();
|
||||
|
||||
Session::set_session(
|
||||
&mut req,
|
||||
vec![("key".to_string(), serde_json::to_string(&10).unwrap())],
|
||||
);
|
||||
|
||||
let session = req.head_mut().get_session();
|
||||
let res = session.get::<u32>("key").unwrap();
|
||||
assert_eq!(res, Some(10));
|
||||
}
|
||||
|
||||
#[actix_web::test]
|
||||
async fn purge_session() {
|
||||
let req = test::TestRequest::default().to_srv_request();
|
||||
|
Reference in New Issue
Block a user