mirror of
https://github.com/fafhrd91/actix-web
synced 2024-12-18 01:43:58 +01:00
restore cookie methods on ServiceRequest
This commit is contained in:
parent
8ffb1f2011
commit
35f8188410
@ -1,14 +1,18 @@
|
|||||||
use std::cell::{Ref, RefMut};
|
use std::{
|
||||||
use std::str;
|
cell::{Ref, RefMut},
|
||||||
|
str,
|
||||||
|
};
|
||||||
|
|
||||||
use encoding_rs::{Encoding, UTF_8};
|
use encoding_rs::{Encoding, UTF_8};
|
||||||
use http::header;
|
use http::header;
|
||||||
use mime::Mime;
|
use mime::Mime;
|
||||||
|
|
||||||
use crate::error::{ContentTypeError, ParseError};
|
use crate::{
|
||||||
use crate::extensions::Extensions;
|
error::{ContentTypeError, ParseError},
|
||||||
use crate::header::{Header, HeaderMap};
|
header::{Header, HeaderMap},
|
||||||
use crate::payload::Payload;
|
payload::Payload,
|
||||||
|
Extensions,
|
||||||
|
};
|
||||||
|
|
||||||
/// Trait that implements general purpose operations on HTTP messages.
|
/// Trait that implements general purpose operations on HTTP messages.
|
||||||
pub trait HttpMessage: Sized {
|
pub trait HttpMessage: Sized {
|
||||||
|
@ -9,6 +9,7 @@ use actix_http::{
|
|||||||
};
|
};
|
||||||
use actix_router::{IntoPattern, Path, Resource, ResourceDef, Url};
|
use actix_router::{IntoPattern, Path, Resource, ResourceDef, Url};
|
||||||
use actix_service::{IntoServiceFactory, ServiceFactory};
|
use actix_service::{IntoServiceFactory, ServiceFactory};
|
||||||
|
use cookie::{Cookie, ParseError as CookieParseError};
|
||||||
|
|
||||||
use crate::dev::insert_slash;
|
use crate::dev::insert_slash;
|
||||||
use crate::guard::Guard;
|
use crate::guard::Guard;
|
||||||
@ -244,6 +245,17 @@ impl ServiceRequest {
|
|||||||
None
|
None
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "cookies")]
|
||||||
|
pub fn cookies(&self) -> Result<Ref<'_, Vec<Cookie<'static>>>, CookieParseError> {
|
||||||
|
self.req.cookies()
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Return request cookie.
|
||||||
|
#[cfg(feature = "cookies")]
|
||||||
|
pub fn cookie(&self, name: &str) -> Option<Cookie<'static>> {
|
||||||
|
self.req.cookie(name)
|
||||||
|
}
|
||||||
|
|
||||||
/// Set request payload.
|
/// Set request payload.
|
||||||
pub fn set_payload(&mut self, payload: Payload) {
|
pub fn set_payload(&mut self, payload: Payload) {
|
||||||
self.payload = payload;
|
self.payload = payload;
|
||||||
|
Loading…
Reference in New Issue
Block a user