mirror of
https://github.com/actix/actix-extras.git
synced 2024-11-27 17:22:57 +01:00
update examples
This commit is contained in:
parent
f73f97353b
commit
f2b3dc5625
@ -33,10 +33,12 @@ async fn index(info: web::Path<(u32, String)>) -> impl Responder {
|
||||
format!("Hello {}! id:{}", info.1, info.0)
|
||||
}
|
||||
|
||||
fn main() -> std::io::Result<()> {
|
||||
#[actix_rt::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
HttpServer::new(|| App::new().service(index))
|
||||
.bind("127.0.0.1:8080")?
|
||||
.run()
|
||||
.start()
|
||||
.await
|
||||
}
|
||||
```
|
||||
|
||||
|
@ -16,7 +16,8 @@ async fn no_params() -> &'static str {
|
||||
"Hello world!\r\n"
|
||||
}
|
||||
|
||||
fn main() -> std::io::Result<()> {
|
||||
#[actix_rt::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "actix_server=info,actix_web=info");
|
||||
env_logger::init();
|
||||
|
||||
@ -41,5 +42,6 @@ fn main() -> std::io::Result<()> {
|
||||
})
|
||||
.bind("127.0.0.1:8080")?
|
||||
.workers(1)
|
||||
.run()
|
||||
.start()
|
||||
.await
|
||||
}
|
||||
|
@ -1,27 +1,25 @@
|
||||
use actix_http::Error;
|
||||
use actix_rt::System;
|
||||
|
||||
fn main() -> Result<(), Error> {
|
||||
#[actix_rt::main]
|
||||
async fn main() -> Result<(), Error> {
|
||||
std::env::set_var("RUST_LOG", "actix_http=trace");
|
||||
env_logger::init();
|
||||
|
||||
System::new("test").block_on(async {
|
||||
let client = awc::Client::new();
|
||||
let client = awc::Client::new();
|
||||
|
||||
// Create request builder, configure request and send
|
||||
let mut response = client
|
||||
.get("https://www.rust-lang.org/")
|
||||
.header("User-Agent", "Actix-web")
|
||||
.send()
|
||||
.await?;
|
||||
// Create request builder, configure request and send
|
||||
let mut response = client
|
||||
.get("https://www.rust-lang.org/")
|
||||
.header("User-Agent", "Actix-web")
|
||||
.send()
|
||||
.await?;
|
||||
|
||||
// server http response
|
||||
println!("Response: {:?}", response);
|
||||
// server http response
|
||||
println!("Response: {:?}", response);
|
||||
|
||||
// read response body
|
||||
let body = response.body().await?;
|
||||
println!("Downloaded: {:?} bytes", body.len());
|
||||
// read response body
|
||||
let body = response.body().await?;
|
||||
println!("Downloaded: {:?} bytes", body.len());
|
||||
|
||||
Ok(())
|
||||
})
|
||||
Ok(())
|
||||
}
|
||||
|
@ -19,7 +19,8 @@ async fn no_params() -> &'static str {
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
fn main() -> std::io::Result<()> {
|
||||
#[actix_rt::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "actix_server=info,actix_web=info");
|
||||
env_logger::init();
|
||||
|
||||
@ -44,7 +45,8 @@ fn main() -> std::io::Result<()> {
|
||||
})
|
||||
.bind_uds("/Users/fafhrd91/uds-test")?
|
||||
.workers(1)
|
||||
.run()
|
||||
.start()
|
||||
.await
|
||||
}
|
||||
|
||||
#[cfg(not(unix))]
|
||||
|
Loading…
Reference in New Issue
Block a user