Some checks failed
continuous-integration/drone/push Build is failing
Signed-off-by: kjuulh <contact@kjuulh.io>
28 lines
626 B
Rust
28 lines
626 B
Rust
use std::net::SocketAddr;
|
|
|
|
use axum::{response::IntoResponse, routing::get, Router};
|
|
|
|
use crate::app::SharedApp;
|
|
|
|
pub async fn axum_serve(host: SocketAddr, app: SharedApp) -> anyhow::Result<()> {
|
|
let app = Router::new()
|
|
.route("/ping", get(pong))
|
|
.route("/", get(root))
|
|
.with_state(app);
|
|
|
|
tracing::info!("listening on {}", host);
|
|
let listener = tokio::net::TcpListener::bind(host).await.unwrap();
|
|
|
|
axum::serve(listener, app.into_make_service()).await?;
|
|
|
|
Ok(())
|
|
}
|
|
|
|
async fn pong() -> impl IntoResponse {
|
|
"pong!"
|
|
}
|
|
|
|
async fn root() -> &'static str {
|
|
"Hello, flux-releaser!"
|
|
}
|