Initial schema for webhook.

This commit is contained in:
Tom Alexander
2024-07-14 16:38:07 -04:00
parent ab5db8aded
commit 14373c21dd
4 changed files with 26 additions and 1 deletions

View File

@@ -1,3 +1,4 @@
#![forbid(unsafe_code)]
use axum::http::StatusCode;
use axum::routing::get;
use axum::routing::post;

View File

@@ -1,11 +1,32 @@
use axum::http::HeaderMap;
use axum::http::StatusCode;
use axum::Json;
use serde::Deserialize;
use serde::Serialize;
use serde_json::Value;
pub(crate) async fn hook() -> (StatusCode, Json<HookResponse>) {
pub(crate) async fn hook(
headers: HeaderMap,
Json(payload): Json<HookRequest>,
) -> (StatusCode, Json<HookResponse>) {
(StatusCode::OK, Json(HookResponse { ok: true }))
}
#[allow(dead_code)]
#[derive(Deserialize)]
pub(crate) struct HookRequest {
#[serde(rename = "ref")]
ref_field: String,
before: String,
compare_url: String,
commits: Value,
total_commits: u64,
head_commit: Value,
repository: Value,
pusher: Value,
sender: Value,
}
#[derive(Serialize)]
pub(crate) struct HookResponse {
ok: bool,