feat: Process events with conductor object
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
a73111b36f
commit
96cd918dfe
1 changed files with 4 additions and 10 deletions
|
@ -19,6 +19,8 @@ use std::collections::HashMap;
|
|||
use actix_web::{web, HttpRequest, HttpResponse, Responder};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
use libconductor::{Conductor, EventType};
|
||||
|
||||
use crate::errors::*;
|
||||
use crate::AppCtx;
|
||||
use crate::*;
|
||||
|
@ -42,23 +44,15 @@ pub fn services(cfg: &mut web::ServiceConfig) {
|
|||
cfg.service(post_event);
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize, Debug)]
|
||||
#[serde(untagged)]
|
||||
enum EventType {
|
||||
NewHostname(String),
|
||||
}
|
||||
|
||||
#[actix_web_codegen_const_routes::post(path = "API_V1_ROUTES.webhook.post_event")]
|
||||
async fn post_event(ctx: AppCtx, payload: web::Json<EventType>) -> ServiceResult<impl Responder> {
|
||||
ctx.conductor.process(payload.into_inner()).await;
|
||||
Ok(HttpResponse::Created())
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub mod tests {
|
||||
use actix_web::{
|
||||
http::{header, StatusCode},
|
||||
test, App,
|
||||
};
|
||||
use actix_web::{http::StatusCode, test, App};
|
||||
|
||||
use super::*;
|
||||
|
||||
|
|
Loading…
Reference in a new issue