1
0
Fork 0
mirror of https://github.com/actix/actix-web.git synced 2024-06-11 09:49:29 +00:00

use env_logger builders in examples

This commit is contained in:
Rob Ede 2021-01-07 02:41:05 +00:00
parent dc23559f23
commit d3c476b8c2
No known key found for this signature in database
GPG key ID: C2A3B36E841A91E6
4 changed files with 5 additions and 10 deletions

View file

@ -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)

View file

@ -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()

View file

@ -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
}
}

View file

@ -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(),