mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-24 00:21:08 +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::str;
|
||||
use std::{
|
||||
cell::{Ref, RefMut},
|
||||
str,
|
||||
};
|
||||
|
||||
use encoding_rs::{Encoding, UTF_8};
|
||||
use http::header;
|
||||
use mime::Mime;
|
||||
|
||||
use crate::error::{ContentTypeError, ParseError};
|
||||
use crate::extensions::Extensions;
|
||||
use crate::header::{Header, HeaderMap};
|
||||
use crate::payload::Payload;
|
||||
use crate::{
|
||||
error::{ContentTypeError, ParseError},
|
||||
header::{Header, HeaderMap},
|
||||
payload::Payload,
|
||||
Extensions,
|
||||
};
|
||||
|
||||
/// Trait that implements general purpose operations on HTTP messages.
|
||||
pub trait HttpMessage: Sized {
|
||||
|
@ -9,6 +9,7 @@ use actix_http::{
|
||||
};
|
||||
use actix_router::{IntoPattern, Path, Resource, ResourceDef, Url};
|
||||
use actix_service::{IntoServiceFactory, ServiceFactory};
|
||||
use cookie::{Cookie, ParseError as CookieParseError};
|
||||
|
||||
use crate::dev::insert_slash;
|
||||
use crate::guard::Guard;
|
||||
@ -244,6 +245,17 @@ impl ServiceRequest {
|
||||
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.
|
||||
pub fn set_payload(&mut self, payload: Payload) {
|
||||
self.payload = payload;
|
||||
|
Loading…
Reference in New Issue
Block a user