Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit fe3aaefe authored by Scallss's avatar Scallss
Browse files

Implement subscribe function in Notification controller.

parent 86a3a4ac
Branches
No related tags found
No related merge requests found
use rocket::fairing::AdHoc; use rocket::fairing::AdHoc;
use crate::model::notification::Notification;
pub mod notification; pub mod notification;
pub fn route_stage() -> AdHoc { pub fn route_stage() -> AdHoc {
return AdHoc::on_ignite("Initializing controller routes...", |rocket| async { return AdHoc::on_ignite("Initializing controller routes...", |rocket| async {
rocket rocket
.mount("/", routes![]) .mount("/", routes![notification::subscribe])
}); });
} }
...@@ -3,4 +3,12 @@ use rocket::serde::json::Json; ...@@ -3,4 +3,12 @@ use rocket::serde::json::Json;
use bambangshop_receiver::Result; use bambangshop_receiver::Result;
use crate::model::notification::Notification; use crate::model::notification::Notification;
use crate::model::subscriber::SubscriberRequest; use crate::model::subscriber::SubscriberRequest;
use crate::service::notification::NotificationService; use crate::service::notification::NotificationService;
\ No newline at end of file
#[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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment