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
|
//! [`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 super::{Extension, FromRequestParts};
|
||||||
use crate::{middleware::AddExtension, serve::IncomingStream};
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use http::request::Parts;
|
use http::request::Parts;
|
||||||
use std::{
|
use std::{
|
||||||
@@ -82,11 +83,16 @@ pub trait Connected<T>: Clone + Send + Sync + 'static {
|
|||||||
fn connect_info(target: T) -> Self;
|
fn connect_info(target: T) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Connected<IncomingStream<'_>> for SocketAddr {
|
#[cfg(all(feature = "tokio", feature = "http1"))]
|
||||||
fn connect_info(target: IncomingStream<'_>) -> Self {
|
const _: () = {
|
||||||
target.remote_addr()
|
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>
|
impl<S, C, T> Service<T> for IntoMakeServiceWithConnectInfo<S, C>
|
||||||
where
|
where
|
||||||
@@ -210,7 +216,7 @@ where
|
|||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
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 std::net::SocketAddr;
|
||||||
use tokio::net::TcpListener;
|
use tokio::net::TcpListener;
|
||||||
|
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
// for `axum::serve(listener, handler)`
|
// for `axum::serve(listener, handler)`
|
||||||
#[cfg(feature = "tokio")]
|
#[cfg(all(feature = "tokio", feature = "http1"))]
|
||||||
const _: () = {
|
const _: () = {
|
||||||
use crate::serve::IncomingStream;
|
use crate::serve::IncomingStream;
|
||||||
|
|
||||||
|
|||||||
@@ -1232,7 +1232,7 @@ where
|
|||||||
}
|
}
|
||||||
|
|
||||||
// for `axum::serve(listener, router)`
|
// for `axum::serve(listener, router)`
|
||||||
#[cfg(feature = "tokio")]
|
#[cfg(all(feature = "tokio", feature = "http1"))]
|
||||||
const _: () = {
|
const _: () = {
|
||||||
use crate::serve::IncomingStream;
|
use crate::serve::IncomingStream;
|
||||||
|
|
||||||
|
|||||||
@@ -604,7 +604,7 @@ impl Router {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// for `axum::serve(listener, router)`
|
// for `axum::serve(listener, router)`
|
||||||
#[cfg(feature = "tokio")]
|
#[cfg(all(feature = "tokio", feature = "http1"))]
|
||||||
const _: () = {
|
const _: () = {
|
||||||
use crate::serve::IncomingStream;
|
use crate::serve::IncomingStream;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user