mirror of
https://github.com/tokio-rs/axum.git
synced 2026-09-08 00:00:24 +02:00
Remove impl Connected<&AddrStream> for SocketAddr (#1954)
This commit is contained in:
@@ -191,7 +191,6 @@ allowed = [
|
|||||||
"futures_util",
|
"futures_util",
|
||||||
"http",
|
"http",
|
||||||
"http_body",
|
"http_body",
|
||||||
"hyper",
|
|
||||||
"serde",
|
"serde",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tower_layer",
|
"tower_layer",
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ use super::{Extension, FromRequestParts};
|
|||||||
use crate::{middleware::AddExtension, serve::IncomingStream};
|
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 hyper::server::conn::AddrStream;
|
|
||||||
use std::{
|
use std::{
|
||||||
convert::Infallible,
|
convert::Infallible,
|
||||||
fmt,
|
fmt,
|
||||||
@@ -83,12 +82,6 @@ pub trait Connected<T>: Clone + Send + Sync + 'static {
|
|||||||
fn connect_info(target: T) -> Self;
|
fn connect_info(target: T) -> Self;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Connected<&AddrStream> for SocketAddr {
|
|
||||||
fn connect_info(target: &AddrStream) -> Self {
|
|
||||||
target.remote_addr()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Connected<IncomingStream<'_>> for SocketAddr {
|
impl Connected<IncomingStream<'_>> for SocketAddr {
|
||||||
fn connect_info(target: IncomingStream<'_>) -> Self {
|
fn connect_info(target: IncomingStream<'_>) -> Self {
|
||||||
target.remote_addr()
|
target.remote_addr()
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
use openssl::ssl::{Ssl, SslAcceptor, SslFiletype, SslMethod};
|
use openssl::ssl::{Ssl, SslAcceptor, SslFiletype, SslMethod};
|
||||||
use tokio_openssl::SslStream;
|
use tokio_openssl::SslStream;
|
||||||
|
|
||||||
use axum::{body::Body, extract::ConnectInfo, http::Request, routing::get, Router};
|
use axum::{body::Body, http::Request, routing::get, Router};
|
||||||
use futures_util::future::poll_fn;
|
use futures_util::future::poll_fn;
|
||||||
use hyper::server::{
|
use hyper::server::{
|
||||||
accept::Accept,
|
accept::Accept,
|
||||||
conn::{AddrIncoming, Http},
|
conn::{AddrIncoming, Http},
|
||||||
};
|
};
|
||||||
use std::{net::SocketAddr, path::PathBuf, pin::Pin, sync::Arc};
|
use std::{path::PathBuf, pin::Pin, sync::Arc};
|
||||||
use tokio::net::TcpListener;
|
use tokio::net::TcpListener;
|
||||||
use tower::MakeService;
|
use tower::MakeService;
|
||||||
|
|
||||||
@@ -52,9 +52,7 @@ async fn main() {
|
|||||||
|
|
||||||
let protocol = Arc::new(Http::new());
|
let protocol = Arc::new(Http::new());
|
||||||
|
|
||||||
let mut app = Router::new()
|
let mut app = Router::new().route("/", get(handler)).into_make_service();
|
||||||
.route("/", get(handler))
|
|
||||||
.into_make_service_with_connect_info::<SocketAddr>();
|
|
||||||
|
|
||||||
tracing::info!("listening on https://localhost:3000");
|
tracing::info!("listening on https://localhost:3000");
|
||||||
|
|
||||||
@@ -83,6 +81,6 @@ async fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handler(ConnectInfo(addr): ConnectInfo<SocketAddr>) -> String {
|
async fn handler() -> &'static str {
|
||||||
addr.to_string()
|
"Hello, World!"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
//! cargo run -p example-low-level-rustls
|
//! cargo run -p example-low-level-rustls
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
use axum::{extract::ConnectInfo, extract::Request, routing::get, Router};
|
use axum::{extract::Request, routing::get, Router};
|
||||||
use futures_util::future::poll_fn;
|
use futures_util::future::poll_fn;
|
||||||
use hyper::server::{
|
use hyper::server::{
|
||||||
accept::Accept,
|
accept::Accept,
|
||||||
@@ -14,7 +14,6 @@ use rustls_pemfile::{certs, pkcs8_private_keys};
|
|||||||
use std::{
|
use std::{
|
||||||
fs::File,
|
fs::File,
|
||||||
io::BufReader,
|
io::BufReader,
|
||||||
net::SocketAddr,
|
|
||||||
path::{Path, PathBuf},
|
path::{Path, PathBuf},
|
||||||
pin::Pin,
|
pin::Pin,
|
||||||
sync::Arc,
|
sync::Arc,
|
||||||
@@ -55,7 +54,7 @@ async fn main() {
|
|||||||
|
|
||||||
let mut app = Router::<()>::new()
|
let mut app = Router::<()>::new()
|
||||||
.route("/", get(handler))
|
.route("/", get(handler))
|
||||||
.into_make_service_with_connect_info::<SocketAddr>();
|
.into_make_service();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let stream = poll_fn(|cx| Pin::new(&mut listener).poll_accept(cx))
|
let stream = poll_fn(|cx| Pin::new(&mut listener).poll_accept(cx))
|
||||||
@@ -77,8 +76,8 @@ async fn main() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handler(ConnectInfo(addr): ConnectInfo<SocketAddr>) -> String {
|
async fn handler() -> &'static str {
|
||||||
addr.to_string()
|
"Hello, World!"
|
||||||
}
|
}
|
||||||
|
|
||||||
fn rustls_server_config(key: impl AsRef<Path>, cert: impl AsRef<Path>) -> Arc<ServerConfig> {
|
fn rustls_server_config(key: impl AsRef<Path>, cert: impl AsRef<Path>) -> Arc<ServerConfig> {
|
||||||
|
|||||||
Reference in New Issue
Block a user