Add a webhook endpoint.
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
use axum::http::StatusCode;
|
||||
use axum::routing::get;
|
||||
use axum::routing::post;
|
||||
use axum::Json;
|
||||
use axum::Router;
|
||||
use serde::Serialize;
|
||||
@@ -7,6 +8,10 @@ use tower_http::trace::TraceLayer;
|
||||
use tracing_subscriber::layer::SubscriberExt;
|
||||
use tracing_subscriber::util::SubscriberInitExt;
|
||||
|
||||
use self::webhook::hook;
|
||||
|
||||
mod webhook;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
tracing_subscriber::registry()
|
||||
@@ -19,6 +24,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
.init();
|
||||
let app = Router::new()
|
||||
.route("/health", get(health))
|
||||
.route("/hook", post(hook))
|
||||
.layer(TraceLayer::new_for_http());
|
||||
|
||||
let listener = tokio::net::TcpListener::bind("0.0.0.0:8080").await?;
|
||||
|
||||
12
src/webhook.rs
Normal file
12
src/webhook.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
use axum::http::StatusCode;
|
||||
use axum::Json;
|
||||
use serde::Serialize;
|
||||
|
||||
pub(crate) async fn hook() -> (StatusCode, Json<HookResponse>) {
|
||||
(StatusCode::OK, Json(HookResponse { ok: true }))
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub(crate) struct HookResponse {
|
||||
ok: bool,
|
||||
}
|
||||
Reference in New Issue
Block a user