diff --git a/src/controller/mod.rs b/src/controller/mod.rs index f76c4f36acaabeed2b51c51cfca28dd3f8a20010..b6d9501fe32101db8245529f1f151a46339e2d92 100644 --- a/src/controller/mod.rs +++ b/src/controller/mod.rs @@ -5,7 +5,11 @@ pub fn route_stage() -> AdHoc { return AdHoc::on_ignite("Initializing controller routes...", |rocket| async { rocket.mount( "/", - routes![notification::subscribe, notification::unsubscribe], + routes![ + notification::subscribe, + notification::unsubscribe, + notification::receive + ], ) }); } diff --git a/src/controller/notification.rs b/src/controller/notification.rs index 0677a67311568e821ffdfbafbe8df60e99332bc8..18af25485aa0b1e48c1d0f11c5eed162a336e5e0 100644 --- a/src/controller/notification.rs +++ b/src/controller/notification.rs @@ -20,3 +20,11 @@ pub fn unsubscribe(product_type: &str) -> Result<Json<SubscriberRequest>> { Err(e) => Err(e), }; } + +#[post("/receive", data = "<notification>")] +pub fn receive(notification: Json<Notification>) -> Result<Json<Notification>> { + return match NotificationService::receive_notification(notification.into_inner()) { + Ok(f) => Ok(Json::from(f)), + Err(e) => Err(e), + }; +}