Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit eaa4d0e9 authored by Ida Made Revindra Dikta Mahendra's avatar Ida Made Revindra Dikta Mahendra
Browse files

[CHORE]: Implement subscribe function in Notification controller

parent db1c693c
No related branches found
No related tags found
No related merge requests found
......@@ -7,6 +7,6 @@ pub fn route_stage() -> AdHoc {
return AdHoc::on_ignite("Initializing controller routes...", |rocket| async {
rocket
.mount("/product", routes![product::create, product::list, product::read, product::delete])
.mount("/notification", routes![])
.mount("/notification", routes![notification::subscribe])
});
}
......@@ -3,4 +3,12 @@ use rocket::serde::json::Json;
use bambangshop::Result;
use crate::model::subscriber::Subscriber;
use crate::service::notification::NotificationService;
\ No newline at end of file
use crate::service::notification::NotificationService;
#[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.
Finish editing this message first!
Please register or to comment