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

re-arrange modules and exports

This commit is contained in:
Nikolay Kim
2018-03-30 17:31:18 -07:00
parent b16419348e
commit 9e751de707
49 changed files with 373 additions and 483 deletions

View File

@ -17,10 +17,8 @@
//! # Example
//!
//! ```rust
//! # extern crate http;
//! # extern crate actix_web;
//! # use actix_web::*;
//! use http::header;
//! use actix_web::{Application, HttpRequest, http, httpcodes};
//! use actix_web::middleware::cors;
//!
//! fn index(mut req: HttpRequest) -> &'static str {
@ -33,13 +31,13 @@
//! cors::Cors::build() // <- Construct CORS middleware
//! .allowed_origin("https://www.rust-lang.org/")
//! .allowed_methods(vec!["GET", "POST"])
//! .allowed_headers(vec![header::AUTHORIZATION, header::ACCEPT])
//! .allowed_header(header::CONTENT_TYPE)
//! .allowed_headers(vec![http::header::AUTHORIZATION, http::header::ACCEPT])
//! .allowed_header(http::header::CONTENT_TYPE)
//! .max_age(3600)
//! .finish().expect("Can not create CORS middleware")
//! .register(r); // <- Register CORS middleware
//! r.method(Method::GET).f(|_| httpcodes::HttpOk);
//! r.method(Method::HEAD).f(|_| httpcodes::HttpMethodNotAllowed);
//! r.method(http::Method::GET).f(|_| httpcodes::HttpOk);
//! r.method(http::Method::HEAD).f(|_| httpcodes::HttpMethodNotAllowed);
//! })
//! .finish();
//! }

View File

@ -22,11 +22,10 @@
//!
//! ```
//! # extern crate actix_web;
//! # use actix_web::*;
//!
//! use actix_web::{Application, HttpRequest, http, httpcodes};
//! use actix_web::middleware::csrf;
//!
//! fn handle_post(_req: HttpRequest) -> &'static str {
//! fn handle_post(_: HttpRequest) -> &'static str {
//! "This action should only be triggered with requests from the same site"
//! }
//!
@ -37,8 +36,8 @@
//! .allowed_origin("https://www.example.com")
//! .finish())
//! .resource("/", |r| {
//! r.method(Method::GET).f(|_| httpcodes::HttpOk);
//! r.method(Method::POST).f(handle_post);
//! r.method(http::Method::GET).f(|_| httpcodes::HttpOk);
//! r.method(http::Method::POST).f(handle_post);
//! })
//! .finish();
//! }

View File

@ -13,7 +13,7 @@ use middleware::{Response, Middleware};
///
/// ```rust
/// # extern crate actix_web;
/// use actix_web::*;
/// use actix_web::{Application, http, httpcodes, middleware};
///
/// fn main() {
/// let app = Application::new()
@ -22,8 +22,8 @@ use middleware::{Response, Middleware};
/// .header("X-Version", "0.2")
/// .finish())
/// .resource("/test", |r| {
/// r.method(Method::GET).f(|_| httpcodes::HttpOk);
/// r.method(Method::HEAD).f(|_| httpcodes::HttpMethodNotAllowed);
/// r.method(http::Method::GET).f(|_| httpcodes::HttpOk);
/// r.method(http::Method::HEAD).f(|_| httpcodes::HttpMethodNotAllowed);
/// })
/// .finish();
/// }