Initial schema for webhook.
This commit is contained in:
parent
ab5db8aded
commit
14373c21dd
1
Cargo.lock
generated
1
Cargo.lock
generated
@ -831,6 +831,7 @@ version = "0.0.1"
|
||||
dependencies = [
|
||||
"axum",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"tokio",
|
||||
"tower-http",
|
||||
"tracing",
|
||||
|
@ -21,6 +21,8 @@ include = [
|
||||
# default form, http1, json, matched-path, original-uri, query, tokio, tower-log, tracing
|
||||
axum = { version = "0.7.5", default-features = false, features = ["tokio", "http1", "http2", "json"] }
|
||||
serde = { version = "1.0.204", features = ["derive"] }
|
||||
# default std
|
||||
serde_json = { version = "1.0.120", default-features = false, features = ["std"] }
|
||||
tokio = { version = "1.38.0", default-features = false, features = ["macros", "process", "rt", "rt-multi-thread"] }
|
||||
tower-http = { version = "0.5.2", default-features = false, features = ["trace"] }
|
||||
# default attributes, std, tracing-attributes
|
||||
|
@ -1,3 +1,4 @@
|
||||
#![forbid(unsafe_code)]
|
||||
use axum::http::StatusCode;
|
||||
use axum::routing::get;
|
||||
use axum::routing::post;
|
||||
|
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user