mirror of
https://github.com/actix/actix-extras.git
synced 2025-06-26 18:37:41 +02:00
simplify http response construction; deprecate httpcodes
This commit is contained in:
@ -15,8 +15,8 @@ use futures::{Future, Poll, Async};
|
||||
use tokio_core::reactor::Timeout;
|
||||
|
||||
use pipeline::Pipeline;
|
||||
use httpcodes::HttpNotFound;
|
||||
use httprequest::HttpRequest;
|
||||
use httpresponse::HttpResponse;
|
||||
use error::{ParseError, PayloadError, ResponseError};
|
||||
use payload::{Payload, PayloadWriter, PayloadStatus};
|
||||
|
||||
@ -158,7 +158,7 @@ impl<T, H> Http1<T, H>
|
||||
}
|
||||
|
||||
self.tasks.push_back(
|
||||
Entry {pipe: Pipeline::error(HttpNotFound),
|
||||
Entry {pipe: Pipeline::error(HttpResponse::NotFound()),
|
||||
flags: EntryFlags::empty()});
|
||||
continue
|
||||
},
|
||||
|
@ -18,9 +18,9 @@ use tokio_core::reactor::Timeout;
|
||||
|
||||
use pipeline::Pipeline;
|
||||
use error::PayloadError;
|
||||
use httpcodes::HttpNotFound;
|
||||
use httpmessage::HttpMessage;
|
||||
use httprequest::HttpRequest;
|
||||
use httpresponse::HttpResponse;
|
||||
use payload::{Payload, PayloadWriter, PayloadStatus};
|
||||
|
||||
use super::h2writer::H2Writer;
|
||||
@ -318,7 +318,7 @@ impl<H: 'static> Entry<H> {
|
||||
}
|
||||
}
|
||||
|
||||
Entry {task: task.unwrap_or_else(|| Pipeline::error(HttpNotFound)),
|
||||
Entry {task: task.unwrap_or_else(|| Pipeline::error(HttpResponse::NotFound())),
|
||||
payload: psender,
|
||||
stream: H2Writer::new(
|
||||
resp, settings.get_shared_bytes(), Rc::clone(settings)),
|
||||
|
@ -33,6 +33,26 @@ use httpresponse::HttpResponse;
|
||||
pub(crate) const MAX_WRITE_BUFFER_SIZE: usize = 65_536;
|
||||
|
||||
/// Create new http server with application factory
|
||||
///
|
||||
/// ```rust
|
||||
/// # extern crate actix;
|
||||
/// # extern crate actix_web;
|
||||
/// use actix::*;
|
||||
/// use actix_web::{server, Application, HttpResponse};
|
||||
///
|
||||
/// fn main() {
|
||||
/// let sys = actix::System::new("guide");
|
||||
///
|
||||
/// server::new(
|
||||
/// || Application::new()
|
||||
/// .resource("/", |r| r.f(|_| HttpResponse::Ok())))
|
||||
/// .bind("127.0.0.1:59080").unwrap()
|
||||
/// .start();
|
||||
///
|
||||
/// # actix::Arbiter::system().do_send(actix::msgs::SystemExit(0));
|
||||
/// let _ = sys.run();
|
||||
/// }
|
||||
/// ```
|
||||
pub fn new<F, U, H>(factory: F) -> HttpServer<H>
|
||||
where F: Fn() -> U + Sync + Send + 'static,
|
||||
U: IntoIterator<Item=H> + 'static,
|
||||
|
@ -269,7 +269,7 @@ impl<H: IntoHttpHandler> HttpServer<H>
|
||||
///
|
||||
/// HttpServer::new(
|
||||
/// || Application::new()
|
||||
/// .resource("/", |r| r.h(httpcodes::HttpOk)))
|
||||
/// .resource("/", |r| r.h(|_| HttpResponse::Ok())))
|
||||
/// .bind("127.0.0.1:0").expect("Can not bind to 127.0.0.1:0")
|
||||
/// .start();
|
||||
/// # actix::Arbiter::system().do_send(actix::msgs::SystemExit(0));
|
||||
@ -327,7 +327,7 @@ impl<H: IntoHttpHandler> HttpServer<H>
|
||||
/// fn main() {
|
||||
/// HttpServer::new(
|
||||
/// || Application::new()
|
||||
/// .resource("/", |r| r.h(httpcodes::HttpOk)))
|
||||
/// .resource("/", |r| r.h(|_| HttpResponse::Ok())))
|
||||
/// .bind("127.0.0.1:0").expect("Can not bind to 127.0.0.1:0")
|
||||
/// .run();
|
||||
/// }
|
||||
|
Reference in New Issue
Block a user