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:
|
||||
//! <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};
|
||||
|
||||
@ -36,11 +36,7 @@ fn get_conn_info(connection: &dyn Any, data: &mut Extensions) {
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() -> io::Result<()> {
|
||||
if env::var("RUST_LOG").is_err() {
|
||||
env::set_var("RUST_LOG", "info");
|
||||
}
|
||||
|
||||
env_logger::init();
|
||||
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
|
||||
|
||||
HttpServer::new(|| App::new().default_service(web::to(route_whoami)))
|
||||
.on_connect(get_conn_info)
|
||||
|
@ -22,8 +22,7 @@ async fn no_params() -> &'static str {
|
||||
#[cfg(unix)]
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
std::env::set_var("RUST_LOG", "actix_server=info,actix_web=info");
|
||||
env_logger::init();
|
||||
env_logger::init_from_env(env_logger::Env::new().default_filter_or("info"));
|
||||
|
||||
HttpServer::new(|| {
|
||||
App::new()
|
||||
|
@ -417,7 +417,7 @@ impl<B> ServiceResponse<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
|
||||
}
|
||||
}
|
||||
|
@ -126,7 +126,7 @@ where
|
||||
A: Into<Error>,
|
||||
B: Into<Error>,
|
||||
{
|
||||
fn into(err: EitherExtractError<A, B>) -> Error {
|
||||
fn from(err: EitherExtractError<A, B>) -> Error {
|
||||
match err {
|
||||
EitherExtractError::Bytes(err) => err,
|
||||
EitherExtractError::Extract(a_err, _b_err) => a_err.into(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user