mirror of
https://github.com/fafhrd91/actix-web
synced 2024-11-27 17:52:56 +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"]
|
features = ["tls", "alpn", "session", "brotli", "flate2-c"]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
actix = "0.6"
|
actix = "0.6.1"
|
||||||
|
|
||||||
base64 = "0.9"
|
base64 = "0.9"
|
||||||
bitflags = "1.0"
|
bitflags = "1.0"
|
||||||
failure = "0.1.1"
|
failure = "0.1.1"
|
||||||
|
@ -303,18 +303,16 @@ impl ClientConnector {
|
|||||||
/// # use std::process;
|
/// # use std::process;
|
||||||
/// # use actix_web::actix::Actor;
|
/// # use actix_web::actix::Actor;
|
||||||
/// extern crate openssl;
|
/// extern crate openssl;
|
||||||
/// use actix_web::client::{ClientConnector, Connect};
|
/// use actix_web::{actix, client::ClientConnector, client::Connect};
|
||||||
///
|
///
|
||||||
/// use openssl::ssl::{SslConnector, SslMethod};
|
/// use openssl::ssl::{SslConnector, SslMethod};
|
||||||
///
|
///
|
||||||
/// fn main() {
|
/// fn main() {
|
||||||
/// let mut sys = actix_web::actix::System::new("test");
|
/// actix::run(|| {
|
||||||
///
|
|
||||||
/// // Start `ClientConnector` with custom `SslConnector`
|
/// // Start `ClientConnector` with custom `SslConnector`
|
||||||
/// let ssl_conn = SslConnector::builder(SslMethod::tls()).unwrap().build();
|
/// let ssl_conn = SslConnector::builder(SslMethod::tls()).unwrap().build();
|
||||||
/// let conn = ClientConnector::with_connector(ssl_conn).start();
|
/// let conn = ClientConnector::with_connector(ssl_conn).start();
|
||||||
///
|
///
|
||||||
/// sys.block_on(
|
|
||||||
/// conn.send(
|
/// conn.send(
|
||||||
/// Connect::new("https://www.rust-lang.org").unwrap()) // <- connect to host
|
/// Connect::new("https://www.rust-lang.org").unwrap()) // <- connect to host
|
||||||
/// .map_err(|_| ())
|
/// .map_err(|_| ())
|
||||||
@ -322,6 +320,7 @@ impl ClientConnector {
|
|||||||
/// if let Ok(mut stream) = res {
|
/// if let Ok(mut stream) = res {
|
||||||
/// stream.write_all(b"GET / HTTP/1.0\r\n\r\n").unwrap();
|
/// stream.write_all(b"GET / HTTP/1.0\r\n\r\n").unwrap();
|
||||||
/// }
|
/// }
|
||||||
|
/// # actix::System::current().stop();
|
||||||
/// Ok(())
|
/// Ok(())
|
||||||
/// })
|
/// })
|
||||||
/// );
|
/// );
|
||||||
|
@ -6,19 +6,18 @@
|
|||||||
//! # extern crate tokio;
|
//! # extern crate tokio;
|
||||||
//! # use futures::Future;
|
//! # use futures::Future;
|
||||||
//! # use std::process;
|
//! # use std::process;
|
||||||
//! use actix_web::client;
|
//! use actix_web::{actix, client};
|
||||||
//!
|
//!
|
||||||
//! fn main() {
|
//! fn main() {
|
||||||
//! let mut sys = actix_web::actix::System::new("test");
|
//! actix::run(
|
||||||
//!
|
//! || client::get("http://www.rust-lang.org") // <- Create request builder
|
||||||
//! sys.block_on(
|
|
||||||
//! client::get("http://www.rust-lang.org") // <- Create request builder
|
|
||||||
//! .header("User-Agent", "Actix-web")
|
//! .header("User-Agent", "Actix-web")
|
||||||
//! .finish().unwrap()
|
//! .finish().unwrap()
|
||||||
//! .send() // <- Send http request
|
//! .send() // <- Send http request
|
||||||
//! .map_err(|_| ())
|
//! .map_err(|_| ())
|
||||||
//! .and_then(|response| { // <- server http response
|
//! .and_then(|response| { // <- server http response
|
||||||
//! println!("Response: {:?}", response);
|
//! println!("Response: {:?}", response);
|
||||||
|
//! # actix::System::current().stop();
|
||||||
//! Ok(())
|
//! Ok(())
|
||||||
//! })
|
//! })
|
||||||
//! );
|
//! );
|
||||||
@ -66,19 +65,18 @@ impl ResponseError for SendRequestError {
|
|||||||
/// # extern crate env_logger;
|
/// # extern crate env_logger;
|
||||||
/// # use futures::Future;
|
/// # use futures::Future;
|
||||||
/// # use std::process;
|
/// # use std::process;
|
||||||
/// use actix_web::client;
|
/// use actix_web::{actix, client};
|
||||||
///
|
///
|
||||||
/// fn main() {
|
/// fn main() {
|
||||||
/// let mut sys = actix_web::actix::System::new("test");
|
/// actix::run(
|
||||||
///
|
/// || client::get("http://www.rust-lang.org") // <- Create request builder
|
||||||
/// sys.block_on(
|
|
||||||
/// client::get("http://www.rust-lang.org") // <- Create request builder
|
|
||||||
/// .header("User-Agent", "Actix-web")
|
/// .header("User-Agent", "Actix-web")
|
||||||
/// .finish().unwrap()
|
/// .finish().unwrap()
|
||||||
/// .send() // <- Send http request
|
/// .send() // <- Send http request
|
||||||
/// .map_err(|_| ())
|
/// .map_err(|_| ())
|
||||||
/// .and_then(|response| { // <- server http response
|
/// .and_then(|response| { // <- server http response
|
||||||
/// println!("Response: {:?}", response);
|
/// println!("Response: {:?}", response);
|
||||||
|
/// # actix::System::current().stop();
|
||||||
/// Ok(())
|
/// Ok(())
|
||||||
/// }),
|
/// }),
|
||||||
/// );
|
/// );
|
||||||
|
@ -31,19 +31,18 @@ use httprequest::HttpRequest;
|
|||||||
/// # extern crate tokio;
|
/// # extern crate tokio;
|
||||||
/// # use futures::Future;
|
/// # use futures::Future;
|
||||||
/// # use std::process;
|
/// # use std::process;
|
||||||
/// use actix_web::client::ClientRequest;
|
/// use actix_web::{actix, client};
|
||||||
///
|
///
|
||||||
/// fn main() {
|
/// fn main() {
|
||||||
/// let mut sys = actix_web::actix::System::new("test");
|
/// actix::run(
|
||||||
///
|
/// || client::ClientRequest::get("http://www.rust-lang.org") // <- Create request builder
|
||||||
/// sys.block_on(
|
|
||||||
/// ClientRequest::get("http://www.rust-lang.org") // <- Create request builder
|
|
||||||
/// .header("User-Agent", "Actix-web")
|
/// .header("User-Agent", "Actix-web")
|
||||||
/// .finish().unwrap()
|
/// .finish().unwrap()
|
||||||
/// .send() // <- Send http request
|
/// .send() // <- Send http request
|
||||||
/// .map_err(|_| ())
|
/// .map_err(|_| ())
|
||||||
/// .and_then(|response| { // <- server http response
|
/// .and_then(|response| { // <- server http response
|
||||||
/// println!("Response: {:?}", response);
|
/// println!("Response: {:?}", response);
|
||||||
|
/// # actix::System::current().stop();
|
||||||
/// Ok(())
|
/// Ok(())
|
||||||
/// }),
|
/// }),
|
||||||
/// );
|
/// );
|
||||||
|
@ -210,6 +210,7 @@ pub mod actix {
|
|||||||
pub use self::actix::fut;
|
pub use self::actix::fut;
|
||||||
pub use self::actix::msgs;
|
pub use self::actix::msgs;
|
||||||
pub use self::actix::prelude::*;
|
pub use self::actix::prelude::*;
|
||||||
|
pub use self::actix::{run, spawn};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "openssl")]
|
#[cfg(feature = "openssl")]
|
||||||
|
Loading…
Reference in New Issue
Block a user