feat: Process events with conductor object
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Aravinth Manivannan 2022-10-05 17:00:55 +05:30
parent a73111b36f
commit 96cd918dfe
Signed by: realaravinth
GPG key ID: AD9F0F08E855ED88

View file

@ -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::*;