Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit 257339e8 authored by Andrew4Coding's avatar Andrew4Coding
Browse files

Implement subscribe function in Notification controller.

parent 5fe87c56
Branches
No related tags found
No related merge requests found
pub mod product; pub mod product;
pub mod notification; pub mod notification;
use rocket::fairing::AdHoc; use rocket::fairing::AdHoc;
...@@ -7,6 +7,6 @@ pub fn route_stage() -> AdHoc { ...@@ -7,6 +7,6 @@ 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("/product", routes![product::create, product::list, product::read, product::delete]) .mount("/product", routes![product::create, product::list, product::read, product::delete])
.mount("/notification", routes![]) .mount("/notification", routes![notification::subscribe])
}); });
} }
\ No newline at end of file
...@@ -3,4 +3,12 @@ use rocket::serde::json::Json; ...@@ -3,4 +3,12 @@ use rocket::serde::json::Json;
use bambangshop::Result; use bambangshop::Result;
use crate::model::subscriber::Subscriber; use crate::model::subscriber::Subscriber;
use crate::service::notification::NotificationService; use crate::service::notification::NotificationService;
\ No newline at end of file
# [post("/subscribe/<product_type>", data = "<subscriber>")]
pub fn subscribe(product_type: &str, subscriber: Json<Subscriber>) -> Result<Created<Json<Subscriber>>> {
return match NotificationService::subscribe(product_type, subscriber.into_inner()) {
Ok(f) => Ok(Created::new("/").body(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