mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-24 07:53:00 +01:00
Merge pull request #171 from DoumanAsh/without_state_public
Make HttpRequest::without_state public
This commit is contained in:
commit
76fcdc13a3
10
src/fs.rs
10
src/fs.rs
@ -498,18 +498,18 @@ impl<S: 'static> Handler<S> for StaticFiles<S> {
|
|||||||
HttpResponse::Found()
|
HttpResponse::Found()
|
||||||
.header(header::LOCATION, new_path.as_str())
|
.header(header::LOCATION, new_path.as_str())
|
||||||
.finish()
|
.finish()
|
||||||
.respond_to(req.without_state())
|
.respond_to(req.drop_state())
|
||||||
} else if self.show_index {
|
} else if self.show_index {
|
||||||
Directory::new(self.directory.clone(), path)
|
Directory::new(self.directory.clone(), path)
|
||||||
.respond_to(req.without_state())?
|
.respond_to(req.drop_state())?
|
||||||
.respond_to(req.without_state())
|
.respond_to(req.drop_state())
|
||||||
} else {
|
} else {
|
||||||
Ok(self.default.handle(req))
|
Ok(self.default.handle(req))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
NamedFile::open(path)?.set_cpu_pool(self.cpu_pool.clone())
|
NamedFile::open(path)?.set_cpu_pool(self.cpu_pool.clone())
|
||||||
.respond_to(req.without_state())?
|
.respond_to(req.drop_state())?
|
||||||
.respond_to(req.without_state())
|
.respond_to(req.drop_state())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -337,7 +337,7 @@ impl<S, H, R> RouteHandler<S> for WrapHandler<S, H, R>
|
|||||||
S: 'static,
|
S: 'static,
|
||||||
{
|
{
|
||||||
fn handle(&mut self, req: HttpRequest<S>) -> Reply {
|
fn handle(&mut self, req: HttpRequest<S>) -> Reply {
|
||||||
let req2 = req.without_state();
|
let req2 = req.drop_state();
|
||||||
match self.h.handle(req).respond_to(req2) {
|
match self.h.handle(req).respond_to(req2) {
|
||||||
Ok(reply) => reply.into(),
|
Ok(reply) => reply.into(),
|
||||||
Err(err) => Reply::response(err.into()),
|
Err(err) => Reply::response(err.into()),
|
||||||
@ -378,7 +378,7 @@ impl<S, H, F, R, E> RouteHandler<S> for AsyncHandler<S, H, F, R, E>
|
|||||||
S: 'static,
|
S: 'static,
|
||||||
{
|
{
|
||||||
fn handle(&mut self, req: HttpRequest<S>) -> Reply {
|
fn handle(&mut self, req: HttpRequest<S>) -> Reply {
|
||||||
let req2 = req.without_state();
|
let req2 = req.drop_state();
|
||||||
let fut = (self.h)(req)
|
let fut = (self.h)(req)
|
||||||
.map_err(|e| e.into())
|
.map_err(|e| e.into())
|
||||||
.then(move |r| {
|
.then(move |r| {
|
||||||
|
@ -172,7 +172,7 @@ impl<S> HttpRequest<S> {
|
|||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
/// Construct new http request without state.
|
/// Construct new http request without state.
|
||||||
pub(crate) fn without_state(&self) -> HttpRequest {
|
pub fn drop_state(&self) -> HttpRequest {
|
||||||
HttpRequest(self.0.clone(), None, self.2.clone())
|
HttpRequest(self.0.clone(), None, self.2.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -559,7 +559,7 @@ impl<S> TestRequest<S> {
|
|||||||
let req = self.finish();
|
let req = self.finish();
|
||||||
let resp = h.handle(req.clone());
|
let resp = h.handle(req.clone());
|
||||||
|
|
||||||
match resp.respond_to(req.without_state()) {
|
match resp.respond_to(req.drop_state()) {
|
||||||
Ok(resp) => {
|
Ok(resp) => {
|
||||||
match resp.into().into() {
|
match resp.into().into() {
|
||||||
ReplyItem::Message(resp) => Ok(resp),
|
ReplyItem::Message(resp) => Ok(resp),
|
||||||
@ -586,7 +586,7 @@ impl<S> TestRequest<S> {
|
|||||||
let mut core = Core::new().unwrap();
|
let mut core = Core::new().unwrap();
|
||||||
match core.run(fut) {
|
match core.run(fut) {
|
||||||
Ok(r) => {
|
Ok(r) => {
|
||||||
match r.respond_to(req.without_state()) {
|
match r.respond_to(req.drop_state()) {
|
||||||
Ok(reply) => match reply.into().into() {
|
Ok(reply) => match reply.into().into() {
|
||||||
ReplyItem::Message(resp) => Ok(resp),
|
ReplyItem::Message(resp) => Ok(resp),
|
||||||
_ => panic!("Nested async replies are not supported"),
|
_ => panic!("Nested async replies are not supported"),
|
||||||
|
10
src/with.rs
10
src/with.rs
@ -134,7 +134,7 @@ impl<T, S, F, R> Future for WithHandlerFut<T, S, F, R>
|
|||||||
};
|
};
|
||||||
|
|
||||||
let hnd: &mut F = unsafe{&mut *self.hnd.get()};
|
let hnd: &mut F = unsafe{&mut *self.hnd.get()};
|
||||||
let item = match (*hnd)(item).respond_to(self.req.without_state()) {
|
let item = match (*hnd)(item).respond_to(self.req.drop_state()) {
|
||||||
Ok(item) => item.into(),
|
Ok(item) => item.into(),
|
||||||
Err(e) => return Err(e.into()),
|
Err(e) => return Err(e.into()),
|
||||||
};
|
};
|
||||||
@ -241,7 +241,7 @@ impl<T1, T2, S, F, R> Future for WithHandlerFut2<T1, T2, S, F, R>
|
|||||||
Ok(Async::Ready(item2)) => {
|
Ok(Async::Ready(item2)) => {
|
||||||
let hnd: &mut F = unsafe{&mut *self.hnd.get()};
|
let hnd: &mut F = unsafe{&mut *self.hnd.get()};
|
||||||
match (*hnd)(item1, item2)
|
match (*hnd)(item1, item2)
|
||||||
.respond_to(self.req.without_state())
|
.respond_to(self.req.drop_state())
|
||||||
{
|
{
|
||||||
Ok(item) => match item.into().into() {
|
Ok(item) => match item.into().into() {
|
||||||
ReplyItem::Message(resp) =>
|
ReplyItem::Message(resp) =>
|
||||||
@ -289,7 +289,7 @@ impl<T1, T2, S, F, R> Future for WithHandlerFut2<T1, T2, S, F, R>
|
|||||||
|
|
||||||
let hnd: &mut F = unsafe{&mut *self.hnd.get()};
|
let hnd: &mut F = unsafe{&mut *self.hnd.get()};
|
||||||
let item = match (*hnd)(self.item.take().unwrap(), item)
|
let item = match (*hnd)(self.item.take().unwrap(), item)
|
||||||
.respond_to(self.req.without_state())
|
.respond_to(self.req.drop_state())
|
||||||
{
|
{
|
||||||
Ok(item) => item.into(),
|
Ok(item) => item.into(),
|
||||||
Err(err) => return Err(err.into()),
|
Err(err) => return Err(err.into()),
|
||||||
@ -417,7 +417,7 @@ impl<T1, T2, T3, S, F, R> Future for WithHandlerFut3<T1, T2, T3, S, F, R>
|
|||||||
Ok(Async::Ready(item3)) => {
|
Ok(Async::Ready(item3)) => {
|
||||||
let hnd: &mut F = unsafe{&mut *self.hnd.get()};
|
let hnd: &mut F = unsafe{&mut *self.hnd.get()};
|
||||||
match (*hnd)(item1, item2, item3)
|
match (*hnd)(item1, item2, item3)
|
||||||
.respond_to(self.req.without_state())
|
.respond_to(self.req.drop_state())
|
||||||
{
|
{
|
||||||
Ok(item) => match item.into().into() {
|
Ok(item) => match item.into().into() {
|
||||||
ReplyItem::Message(resp) =>
|
ReplyItem::Message(resp) =>
|
||||||
@ -488,7 +488,7 @@ impl<T1, T2, T3, S, F, R> Future for WithHandlerFut3<T1, T2, T3, S, F, R>
|
|||||||
let item = match (*hnd)(self.item1.take().unwrap(),
|
let item = match (*hnd)(self.item1.take().unwrap(),
|
||||||
self.item2.take().unwrap(),
|
self.item2.take().unwrap(),
|
||||||
item)
|
item)
|
||||||
.respond_to(self.req.without_state())
|
.respond_to(self.req.drop_state())
|
||||||
{
|
{
|
||||||
Ok(item) => item.into(),
|
Ok(item) => item.into(),
|
||||||
Err(err) => return Err(err.into()),
|
Err(err) => return Err(err.into()),
|
||||||
|
Loading…
Reference in New Issue
Block a user