mirror of
https://github.com/tokio-rs/axum.git
synced 2026-08-29 00:00:18 +02:00
more cfgs
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ where
|
||||
}
|
||||
|
||||
// for `axum::serve(listener, handler)`
|
||||
#[cfg(feature = "tokio")]
|
||||
#[cfg(all(feature = "tokio", feature = "http1"))]
|
||||
const _: () = {
|
||||
use crate::serve::IncomingStream;
|
||||
|
||||
|
||||
@@ -1232,7 +1232,7 @@ where
|
||||
}
|
||||
|
||||
// for `axum::serve(listener, router)`
|
||||
#[cfg(feature = "tokio")]
|
||||
#[cfg(all(feature = "tokio", feature = "http1"))]
|
||||
const _: () = {
|
||||
use crate::serve::IncomingStream;
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user