splitted health on dedicated mod
This commit is contained in:
parent
7ee03f4d52
commit
921a22e645
1
src/http/mod.rs
Normal file
1
src/http/mod.rs
Normal file
@ -0,0 +1 @@
|
||||
pub mod public;
|
||||
9
src/http/public.rs
Normal file
9
src/http/public.rs
Normal file
@ -0,0 +1,9 @@
|
||||
use axum::{Router, routing::get};
|
||||
|
||||
pub fn router() -> Router {
|
||||
Router::new().route("/health", get(get_health()))
|
||||
}
|
||||
|
||||
fn get_health() -> &'static str {
|
||||
"{'status': 'ok'}"
|
||||
}
|
||||
@ -1,10 +1,10 @@
|
||||
use axum::{Router, routing::get};
|
||||
mod http;
|
||||
|
||||
use axum::Router;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() {
|
||||
let app = Router::new()
|
||||
.route("/", get(|| async { "hello world" }))
|
||||
.route("/health", get(|| async { "ok" }));
|
||||
let app = Router::new().merge(http::public::router());
|
||||
|
||||
let listener = tokio::net::TcpListener::bind("0.0.0.0:8080").await.unwrap();
|
||||
axum::serve(listener, app).await.unwrap();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user