mirror of
https://github.com/fafhrd91/actix-web
synced 2025-01-18 22:01:50 +01:00
use env_logger builders in examples
This commit is contained in:
parent
dc23559f23
commit
d3c476b8c2
@ -4,7 +4,7 @@
|
|||||||
//! For an example of extracting a client TLS certificate, see:
|
//! For an example of extracting a client TLS certificate, see:
|
||||||
//! <https://github.com/actix/examples/tree/HEAD/rustls-client-cert>
|
//! <https://github.com/actix/examples/tree/HEAD/rustls-client-cert>
|
||||||
|
|
||||||
use std::{any::Any, env, io, net::SocketAddr};
|
use std::{any::Any, io, net::SocketAddr};
|
||||||
|
|
||||||
use actix_web::{dev::Extensions, rt::net::TcpStream, web, App, HttpServer};
|
use actix_web::{dev::Extensions, rt::net::TcpStream, web, App, HttpServer};
|
||||||
|
|
||||||
@ -36,11 +36,7 @@ fn get_conn_info(connection: &dyn Any, data: &mut Extensions) {
|
|||||||
|
|
||||||
#[actix_web::main]
|
#[actix_web::main]
|
||||||
async fn main() -> io::Result<()> {
|
async fn main() -> io::Result<()> {
|
||||||
if env::var("RUST_LOG").is_err() {
|
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
|
||||||
env::set_var("RUST_LOG", "info");
|
|
||||||
}
|
|
||||||
|
|
||||||
env_logger::init();
|
|
||||||
|
|
||||||
HttpServer::new(|| App::new().default_service(web::to(route_whoami)))
|
HttpServer::new(|| App::new().default_service(web::to(route_whoami)))
|
||||||
.on_connect(get_conn_info)
|
.on_connect(get_conn_info)
|
||||||
|
@ -22,8 +22,7 @@ async fn no_params() -> &'static str {
|
|||||||
#[cfg(unix)]
|
#[cfg(unix)]
|
||||||
#[actix_web::main]
|
#[actix_web::main]
|
||||||
async fn main() -> std::io::Result<()> {
|
async fn main() -> std::io::Result<()> {
|
||||||
std::env::set_var("RUST_LOG", "actix_server=info,actix_web=info");
|
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
|
||||||
env_logger::init();
|
|
||||||
|
|
||||||
HttpServer::new(|| {
|
HttpServer::new(|| {
|
||||||
App::new()
|
App::new()
|
||||||
|
@ -417,7 +417,7 @@ impl<B> ServiceResponse<B> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl<B> From<ServiceResponse<B>> for Response<B> {
|
impl<B> From<ServiceResponse<B>> for Response<B> {
|
||||||
fn into(res: ServiceResponse<B>) -> Response<B> {
|
fn from(res: ServiceResponse<B>) -> Response<B> {
|
||||||
res.response
|
res.response
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ where
|
|||||||
A: Into<Error>,
|
A: Into<Error>,
|
||||||
B: Into<Error>,
|
B: Into<Error>,
|
||||||
{
|
{
|
||||||
fn into(err: EitherExtractError<A, B>) -> Error {
|
fn from(err: EitherExtractError<A, B>) -> Error {
|
||||||
match err {
|
match err {
|
||||||
EitherExtractError::Bytes(err) => err,
|
EitherExtractError::Bytes(err) => err,
|
||||||
EitherExtractError::Extract(a_err, _b_err) => a_err.into(),
|
EitherExtractError::Extract(a_err, _b_err) => a_err.into(),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user