mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-23 16:21:06 +01:00
better doc api examples
This commit is contained in:
parent
247e8727cb
commit
5c42b0902f
@ -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"
|
||||
|
@ -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();
|
||||
///
|
||||
/// // 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(())
|
||||
/// })
|
||||
/// );
|
||||
|
@ -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(())
|
||||
/// }),
|
||||
/// );
|
||||
|
@ -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(())
|
||||
/// }),
|
||||
/// );
|
||||
|
@ -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")]
|
||||
|
Loading…
Reference in New Issue
Block a user