1
0
mirror of https://github.com/actix/actix-extras.git synced 2025-06-25 09:59:21 +02:00

make possible to use async handler

This commit is contained in:
Nikolay Kim
2017-11-03 13:35:34 -07:00
parent ec3b139273
commit c14e6c9008
6 changed files with 42 additions and 2 deletions

View File

@ -2,6 +2,8 @@ use std::rc::Rc;
use std::sync::Arc;
use bytes::{Bytes, BytesMut};
use route::Frame;
/// Represents various types of http message body.
#[derive(Debug)]
@ -185,6 +187,11 @@ impl AsRef<[u8]> for BinaryBody {
}
}
impl From<BinaryBody> for Frame {
fn from(b: BinaryBody) -> Frame {
Frame::Payload(Some(b))
}
}
#[cfg(test)]
mod tests {

View File

@ -9,6 +9,7 @@ use http::header::{self, HeaderName, HeaderValue};
use Cookie;
use body::Body;
use route::Frame;
/// Represents various types of connection
@ -196,6 +197,12 @@ impl<I: Into<HttpResponse>, E: Into<HttpResponse>> From<Result<I, E>> for HttpRe
}
}
impl From<HttpResponse> for Frame {
fn from(resp: HttpResponse) -> Frame {
Frame::Message(resp)
}
}
#[derive(Debug)]
struct Parts {
version: Option<Version>,

View File

@ -56,7 +56,7 @@ pub use application::{Application, ApplicationBuilder, Middleware};
pub use httprequest::{HttpRequest, UrlEncoded};
pub use httpresponse::{HttpResponse, HttpResponseBuilder};
pub use payload::{Payload, PayloadItem, PayloadError};
pub use route::{Route, RouteFactory, RouteHandler, RouteResult};
pub use route::{Frame, Route, RouteFactory, RouteHandler, RouteResult};
pub use resource::{Reply, Resource, HandlerResult};
pub use recognizer::{Params, RouteRecognizer};
pub use logger::Logger;

View File

@ -25,6 +25,12 @@ pub enum Frame {
Drain(Rc<RefCell<DrainFut>>),
}
impl Frame {
pub fn eof() -> Frame {
Frame::Payload(None)
}
}
/// Trait defines object that could be regestered as resource route
#[allow(unused_variables)]
pub trait RouteHandler<S>: 'static {