mirror of
https://github.com/tokio-rs/axum.git
synced 2025-09-30 14:31:16 +00:00
Fix example-unix-domain-socket
on non-unix platforms (#919)
* remove unused `axum`'s dependency:`tokio-util` * fix `examples/todos`'s `async fn todos_index` iter_overeager_cloned * Add docs to `/examples/async-graphql`, just like other xamples. * remove `examples/async-graphql` unused dependencies `tracing-subscriber` and `trace` * `examples/chat` deps `trace` and `tracing-subscriber` never be used. Add trace `debug` to `chat` * remove `examples/print-request-response` unused dependency `axum-extra` * remove `examples/prometheus-metrics` unused dependency `axum-extra` * remove `examples/reverse-proxy` unused dependencies `tracing-subscriber` and `trace` * `examples/chat` fmt fix * fix `example-unix-domain-socket` compile error on not-unix platforms Co-authored-by: zys864 <zys864@qq.com> Co-authored-by: zys864 <zys864@gmail.com>
This commit is contained in:
parent
3747650ae9
commit
a237edb7c3
@ -4,6 +4,19 @@
|
||||
//! cargo run -p example-unix-domain-socket
|
||||
//! ```
|
||||
|
||||
#[cfg(unix)]
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
unix::server().await;
|
||||
}
|
||||
|
||||
#[cfg(not(unix))]
|
||||
fn main() {
|
||||
println!("This example requires unix")
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
mod unix {
|
||||
use axum::{
|
||||
body::Body,
|
||||
extract::connect_info::{self, ConnectInfo},
|
||||
@ -30,14 +43,7 @@ use tokio::{
|
||||
use tower::BoxError;
|
||||
use tracing_subscriber::{layer::SubscriberExt, util::SubscriberInitExt};
|
||||
|
||||
#[cfg(not(unix))]
|
||||
fn main() {
|
||||
println!("This example requires unix")
|
||||
}
|
||||
|
||||
#[cfg(unix)]
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
pub async fn server() {
|
||||
tracing_subscriber::registry()
|
||||
.with(tracing_subscriber::EnvFilter::new(
|
||||
std::env::var("RUST_LOG").unwrap_or_else(|_| "debug".into()),
|
||||
@ -122,7 +128,10 @@ impl AsyncWrite for ClientConnection {
|
||||
Pin::new(&mut self.stream).poll_write(cx, buf)
|
||||
}
|
||||
|
||||
fn poll_flush(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Result<(), io::Error>> {
|
||||
fn poll_flush(
|
||||
mut self: Pin<&mut Self>,
|
||||
cx: &mut Context<'_>,
|
||||
) -> Poll<Result<(), io::Error>> {
|
||||
Pin::new(&mut self.stream).poll_flush(cx)
|
||||
}
|
||||
|
||||
@ -168,3 +177,4 @@ impl connect_info::Connected<&UnixStream> for UdsConnectInfo {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user