started gitea api impl
This commit is contained in:
+14
-4
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user