1
0
mirror of https://github.com/fafhrd91/actix-web synced 2025-08-31 17:07:01 +02:00

simplify http response construction; deprecate httpcodes

This commit is contained in:
Nikolay Kim
2018-03-30 23:07:33 -07:00
parent 8d8f6bedad
commit 44e3df82f6
58 changed files with 561 additions and 539 deletions

View File

@@ -20,16 +20,13 @@ pub trait Predicate<S> {
///
/// ```rust
/// # extern crate actix_web;
/// # extern crate http;
/// # use actix_web::*;
/// # use actix_web::httpcodes::*;
/// use actix_web::pred;
/// use actix_web::{pred, Application, HttpResponse};
///
/// fn main() {
/// Application::new()
/// .resource("/index.html", |r| r.route()
/// .filter(pred::Any(pred::Get()).or(pred::Post()))
/// .h(HttpMethodNotAllowed));
/// .f(|r| HttpResponse::MethodNotAllowed()));
/// }
/// ```
pub fn Any<S: 'static, P: Predicate<S> + 'static>(pred: P) -> AnyPredicate<S>
@@ -63,17 +60,14 @@ impl<S: 'static> Predicate<S> for AnyPredicate<S> {
///
/// ```rust
/// # extern crate actix_web;
/// # extern crate http;
/// # use actix_web::*;
/// # use actix_web::httpcodes::*;
/// use actix_web::pred;
/// use actix_web::{pred, Application, HttpResponse};
///
/// fn main() {
/// Application::new()
/// .resource("/index.html", |r| r.route()
/// .filter(pred::All(pred::Get())
/// .and(pred::Header("content-type", "plain/text")))
/// .h(HttpMethodNotAllowed));
/// .f(|_| HttpResponse::MethodNotAllowed()));
/// }
/// ```
pub fn All<S: 'static, P: Predicate<S> + 'static>(pred: P) -> AllPredicate<S> {