initial commit
Signed-off-by: NotAShelf <raf@notashelf.dev> Change-Id: I4a6b498153eccd5407510dd541b7f4816a6a6964
This commit is contained in:
commit
6a73d11c4b
124 changed files with 26877 additions and 0 deletions
40
crates/pinakes-server/src/routes/webhooks.rs
Normal file
40
crates/pinakes-server/src/routes/webhooks.rs
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
use axum::Json;
|
||||
use axum::extract::State;
|
||||
use serde::Serialize;
|
||||
|
||||
use crate::error::ApiError;
|
||||
use crate::state::AppState;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct WebhookInfo {
|
||||
pub url: String,
|
||||
pub events: Vec<String>,
|
||||
}
|
||||
|
||||
pub async fn list_webhooks(
|
||||
State(state): State<AppState>,
|
||||
) -> Result<Json<Vec<WebhookInfo>>, ApiError> {
|
||||
let config = state.config.read().await;
|
||||
let hooks: Vec<WebhookInfo> = config
|
||||
.webhooks
|
||||
.iter()
|
||||
.map(|h| WebhookInfo {
|
||||
url: h.url.clone(),
|
||||
events: h.events.clone(),
|
||||
})
|
||||
.collect();
|
||||
Ok(Json(hooks))
|
||||
}
|
||||
|
||||
pub async fn test_webhook(
|
||||
State(state): State<AppState>,
|
||||
) -> Result<Json<serde_json::Value>, ApiError> {
|
||||
let config = state.config.read().await;
|
||||
let count = config.webhooks.len();
|
||||
// Emit a test event to all configured webhooks
|
||||
// In production, the event bus would handle delivery
|
||||
Ok(Json(serde_json::json!({
|
||||
"webhooks_configured": count,
|
||||
"test_sent": true
|
||||
})))
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue