started gitea api impl

This commit is contained in:
2026-06-02 19:52:50 +00:00
parent 1f60f6572f
commit 10ebee389e
6 changed files with 91 additions and 21 deletions
+14 -4
View File
@@ -1,9 +1,10 @@
use axum::body::{Bytes, to_bytes};
use axum::extract::{FromRef, FromRequest};
use axum::response::{IntoResponse, Response};
use axum::extract::{FromRef, FromRequest, State};
use axum::response::IntoResponse;
use axum::routing::{get, post};
use axum::{Json, Router};
use hmac::{Hmac, KeyInit, Mac};
use reqwest::StatusCode;
use serde_json::Value;
use sha2::Sha256;
use subtle::ConstantTimeEq;
@@ -31,8 +32,17 @@ async fn root() -> &'static str {
"Hi, i'm Herald :)"
}
async fn webhook(WebhookExtract(wb): WebhookExtract) -> Result<Response, AppError> {
Ok("lol".into_response())
async fn webhook(
State(app_state): State<AppState>,
WebhookExtract(wb): WebhookExtract,
) -> Result<impl IntoResponse, AppError> {
app_state
.bot_tx
.send(wb)
.await
.map_err(anyhow::Error::from)?;
Ok((StatusCode::CREATED, "Task started"))
}
pub struct WebhookExtract(pub WebhookType);