1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-08-20 12:45:41 +02:00

make HttpRequest::extensions() readonly

This commit is contained in:
Nikolay Kim
2018-05-01 09:05:50 -07:00
parent 48e05a2d87
commit d9a4fadaae
5 changed files with 11 additions and 15 deletions

View File

@@ -100,7 +100,7 @@ pub trait RequestIdentity {
impl<S> RequestIdentity for HttpRequest<S> {
fn identity(&self) -> Option<&str> {
if let Some(id) = self.extensions_ro().get::<IdentityBox>() {
if let Some(id) = self.extensions().get::<IdentityBox>() {
return id.0.identity();
}
None
@@ -183,7 +183,7 @@ impl<S: 'static, T: IdentityPolicy<S>> Middleware<S> for IdentityService<T> {
.from_request(&mut req)
.then(move |res| match res {
Ok(id) => {
req.extensions().insert(IdentityBox(Box::new(id)));
req.extensions_mut().insert(IdentityBox(Box::new(id)));
FutOk(None)
}
Err(err) => FutErr(err),
@@ -194,7 +194,7 @@ impl<S: 'static, T: IdentityPolicy<S>> Middleware<S> for IdentityService<T> {
fn response(
&self, req: &mut HttpRequest<S>, resp: HttpResponse,
) -> Result<Response> {
if let Some(mut id) = req.extensions().remove::<IdentityBox>() {
if let Some(mut id) = req.extensions_mut().remove::<IdentityBox>() {
id.0.write(resp)
} else {
Ok(Response::Done(resp))