use axum::{routing::get, Router};
use axum_client_ip::{SecureClientIp, SecureClientIpSource};
use std::net::SocketAddr;
#[derive(serde::Deserialize)]
struct Config {
ip_source: SecureClientIpSource,
}
async fn handler(SecureClientIp(ip): SecureClientIp) -> String {
ip.to_string()
}
#[tokio::main]
async fn main() {
let config: Config = envy::from_env().unwrap();
let app = Router::new()
.route("/", get(handler))
.layer(config.ip_source.into_extension());
axum::Server::bind(&"0.0.0.0:3000".parse().unwrap())
.serve(app.into_make_service_with_connect_info::<SocketAddr>())
.await
.unwrap()
}