hello_world_unix/hello_world_unix.rs
1//! Run with `cargo run --example hello_world_unix` command.
2//!
3//! To make a request using curl, try `curl --unix-socket /tmp/axum-server.sock http:/localhost`
4
5use axum::{routing::get, Router};
6use std::os::unix::net::SocketAddr;
7
8#[tokio::main]
9async fn main() {
10 let app = Router::new().route("/", get(|| async { "Hello, world!" }));
11
12 let addr = SocketAddr::from_pathname("/tmp/axum-server.sock").unwrap();
13 println!("listening on {}", addr.as_pathname().unwrap().display());
14 axum_server::bind(addr)
15 .serve(app.into_make_service())
16 .await
17 .unwrap();
18}