1
0
Fork 0
mirror of https://github.com/tokio-rs/axum.git synced 2025-04-26 13:56:22 +02:00

more cfgs

This commit is contained in:
David Pedersen 2023-03-24 15:31:52 +01:00
parent b1e9930eb6
commit 91bebd8da9
4 changed files with 15 additions and 9 deletions

View file

@ -4,8 +4,9 @@
//!
//! [`Router::into_make_service_with_connect_info`]: crate::routing::Router::into_make_service_with_connect_info
use crate::extension::AddExtension;
use super::{Extension, FromRequestParts};
use crate::{middleware::AddExtension, serve::IncomingStream};
use async_trait::async_trait;
use http::request::Parts;
use std::{
@ -82,11 +83,16 @@ pub trait Connected<T>: Clone + Send + Sync + 'static {
fn connect_info(target: T) -> Self;
}
impl Connected<IncomingStream<'_>> for SocketAddr {
fn connect_info(target: IncomingStream<'_>) -> Self {
target.remote_addr()
#[cfg(all(feature = "tokio", feature = "http1"))]
const _: () = {
use crate::serve::IncomingStream;
impl Connected<IncomingStream<'_>> for SocketAddr {
fn connect_info(target: IncomingStream<'_>) -> Self {
target.remote_addr()
}
}
}
};
impl<S, C, T> Service<T> for IntoMakeServiceWithConnectInfo<S, C>
where
@ -210,7 +216,7 @@ where
#[cfg(test)]
mod tests {
use super::*;
use crate::{routing::get, test_helpers::TestClient, Router};
use crate::{routing::get, test_helpers::TestClient, Router, serve::IncomingStream};
use std::net::SocketAddr;
use tokio::net::TcpListener;

View file

@ -178,7 +178,7 @@ where
}
// for `axum::serve(listener, handler)`
#[cfg(feature = "tokio")]
#[cfg(all(feature = "tokio", feature = "http1"))]
const _: () = {
use crate::serve::IncomingStream;

View file

@ -1232,7 +1232,7 @@ where
}
// for `axum::serve(listener, router)`
#[cfg(feature = "tokio")]
#[cfg(all(feature = "tokio", feature = "http1"))]
const _: () = {
use crate::serve::IncomingStream;

View file

@ -604,7 +604,7 @@ impl Router {
}
// for `axum::serve(listener, router)`
#[cfg(feature = "tokio")]
#[cfg(all(feature = "tokio", feature = "http1"))]
const _: () = {
use crate::serve::IncomingStream;