1
0
mirror of https://github.com/fafhrd91/actix-web synced 2024-11-24 00:21:08 +01:00

better doc api examples

This commit is contained in:
Nikolay Kim 2018-06-19 12:07:07 +06:00
parent 247e8727cb
commit 5c42b0902f
5 changed files with 21 additions and 23 deletions

View File

@ -50,7 +50,8 @@ flate2-rust = ["flate2/rust_backend"]
features = ["tls", "alpn", "session", "brotli", "flate2-c"]
[dependencies]
actix = "0.6"
actix = "0.6.1"
base64 = "0.9"
bitflags = "1.0"
failure = "0.1.1"

View File

@ -303,18 +303,16 @@ impl ClientConnector {
/// # use std::process;
/// # use actix_web::actix::Actor;
/// extern crate openssl;
/// use actix_web::client::{ClientConnector, Connect};
/// use actix_web::{actix, client::ClientConnector, client::Connect};
///
/// use openssl::ssl::{SslConnector, SslMethod};
///
/// fn main() {
/// let mut sys = actix_web::actix::System::new("test");
///
/// actix::run(|| {
/// // Start `ClientConnector` with custom `SslConnector`
/// let ssl_conn = SslConnector::builder(SslMethod::tls()).unwrap().build();
/// let conn = ClientConnector::with_connector(ssl_conn).start();
///
/// sys.block_on(
/// conn.send(
/// Connect::new("https://www.rust-lang.org").unwrap()) // <- connect to host
/// .map_err(|_| ())
@ -322,6 +320,7 @@ impl ClientConnector {
/// if let Ok(mut stream) = res {
/// stream.write_all(b"GET / HTTP/1.0\r\n\r\n").unwrap();
/// }
/// # actix::System::current().stop();
/// Ok(())
/// })
/// );

View File

@ -6,19 +6,18 @@
//! # extern crate tokio;
//! # use futures::Future;
//! # use std::process;
//! use actix_web::client;
//! use actix_web::{actix, client};
//!
//! fn main() {
//! let mut sys = actix_web::actix::System::new("test");
//!
//! sys.block_on(
//! client::get("http://www.rust-lang.org") // <- Create request builder
//! actix::run(
//! || client::get("http://www.rust-lang.org") // <- Create request builder
//! .header("User-Agent", "Actix-web")
//! .finish().unwrap()
//! .send() // <- Send http request
//! .map_err(|_| ())
//! .and_then(|response| { // <- server http response
//! println!("Response: {:?}", response);
//! # actix::System::current().stop();
//! Ok(())
//! })
//! );
@ -66,19 +65,18 @@ impl ResponseError for SendRequestError {
/// # extern crate env_logger;
/// # use futures::Future;
/// # use std::process;
/// use actix_web::client;
/// use actix_web::{actix, client};
///
/// fn main() {
/// let mut sys = actix_web::actix::System::new("test");
///
/// sys.block_on(
/// client::get("http://www.rust-lang.org") // <- Create request builder
/// actix::run(
/// || client::get("http://www.rust-lang.org") // <- Create request builder
/// .header("User-Agent", "Actix-web")
/// .finish().unwrap()
/// .send() // <- Send http request
/// .map_err(|_| ())
/// .and_then(|response| { // <- server http response
/// println!("Response: {:?}", response);
/// # actix::System::current().stop();
/// Ok(())
/// }),
/// );

View File

@ -31,19 +31,18 @@ use httprequest::HttpRequest;
/// # extern crate tokio;
/// # use futures::Future;
/// # use std::process;
/// use actix_web::client::ClientRequest;
/// use actix_web::{actix, client};
///
/// fn main() {
/// let mut sys = actix_web::actix::System::new("test");
///
/// sys.block_on(
/// ClientRequest::get("http://www.rust-lang.org") // <- Create request builder
/// actix::run(
/// || client::ClientRequest::get("http://www.rust-lang.org") // <- Create request builder
/// .header("User-Agent", "Actix-web")
/// .finish().unwrap()
/// .send() // <- Send http request
/// .map_err(|_| ())
/// .and_then(|response| { // <- server http response
/// println!("Response: {:?}", response);
/// # actix::System::current().stop();
/// Ok(())
/// }),
/// );

View File

@ -210,6 +210,7 @@ pub mod actix {
pub use self::actix::fut;
pub use self::actix::msgs;
pub use self::actix::prelude::*;
pub use self::actix::{run, spawn};
}
#[cfg(feature = "openssl")]