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:
@ -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 {
|
||||
|
@ -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>,
|
||||
|
@ -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;
|
||||
|
@ -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 {
|
||||
|
Reference in New Issue
Block a user