Add health check

This commit is contained in:
Joshua Coles 2023-09-04 17:02:57 +01:00
parent b6e7c870a7
commit cad7a4f7b3

View File

@ -3,7 +3,7 @@ mod error;
use axum::{Extension, Router}; use axum::{Extension, Router};
use std::net::SocketAddr; use std::net::SocketAddr;
use axum::routing::post; use axum::routing::{get, post};
use clap::Parser; use clap::Parser;
use migration::{Migrator, MigratorTrait}; use migration::{Migrator, MigratorTrait};
use crate::ingestion::ingestion::{monzo_batched_csv, monzo_batched_json, monzo_updated}; use crate::ingestion::ingestion::{monzo_batched_csv, monzo_batched_json, monzo_updated};
@ -16,6 +16,10 @@ struct Config {
database_url: String, database_url: String,
} }
async fn health_check() -> &'static str {
"Ok"
}
#[tokio::main] #[tokio::main]
async fn main() -> anyhow::Result<()> { async fn main() -> anyhow::Result<()> {
let config: Config = Config::parse(); let config: Config = Config::parse();
@ -24,6 +28,7 @@ async fn main() -> anyhow::Result<()> {
tracing_subscriber::fmt::init(); tracing_subscriber::fmt::init();
let app = Router::new() let app = Router::new()
.route("/health", get(health_check))
.route("/monzo-updated", post(monzo_updated)) .route("/monzo-updated", post(monzo_updated))
.route("/monzo-batch-export", post(monzo_batched_json)) .route("/monzo-batch-export", post(monzo_batched_json))
.route("/monzo-csv-ingestion", post(monzo_batched_csv)) .route("/monzo-csv-ingestion", post(monzo_batched_csv))