From 4dee73ec9e1172db39f62f966c50ee5560b36e58 Mon Sep 17 00:00:00 2001 From: Ida Made Revindra Dikta Mahendra <idamaderevindra05@gmail.com> Date: Fri, 28 Mar 2025 10:29:50 +0700 Subject: [PATCH] [CHORE]: Implement subscribe function in Notification controller --- src/controller/mod.rs | 2 +- src/controller/notification.rs | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/controller/mod.rs b/src/controller/mod.rs index 5f156e9..e5f9997 100644 --- a/src/controller/mod.rs +++ b/src/controller/mod.rs @@ -5,6 +5,6 @@ use rocket::fairing::AdHoc; pub fn route_stage() -> AdHoc { return AdHoc::on_ignite("Initializing controller routes...", |rocket| async { rocket - .mount("/", routes![]) + .mount("/", routes![notification::subscribe]) }); } diff --git a/src/controller/notification.rs b/src/controller/notification.rs index 063a320..db0effa 100644 --- a/src/controller/notification.rs +++ b/src/controller/notification.rs @@ -3,4 +3,12 @@ use rocket::serde::json::Json; use bambangshop_receiver::Result; use crate::model::notification::Notification; use crate::model::subscriber::SubscriberRequest; -use crate::service::notification::NotificationService; \ No newline at end of file +use crate::service::notification::NotificationService; + +#[get("/subscribe/<product_type>")] +pub fn subscribe(product_type: &str) -> Result<Json<SubscriberRequest>> { + return match NotificationService::subscribe(product_type) { + Ok(f) => Ok(Json::from(f)), + Err(e) => Err(e) + }; +} \ No newline at end of file -- GitLab