Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit 1bb7ff94 authored by Christian Raphael Heryanto's avatar Christian Raphael Heryanto
Browse files

Implement subscribe function in Notification controller.

parent 1d3f097d
No related branches found
No related tags found
No related merge requests found
...@@ -15,6 +15,6 @@ pub fn route_stage() -> AdHoc { ...@@ -15,6 +15,6 @@ pub fn route_stage() -> AdHoc {
product::delete product::delete
], ],
) )
.mount("/notification", routes![]) .mount("/notification", routes![notification::subscribe])
}); });
} }
...@@ -4,3 +4,14 @@ use rocket::serde::json::Json; ...@@ -4,3 +4,14 @@ use rocket::serde::json::Json;
use crate::model::subscriber::Subscriber; use crate::model::subscriber::Subscriber;
use crate::service::notification::NotificationService; use crate::service::notification::NotificationService;
use bambangshop::Result; use bambangshop::Result;
#[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),
};
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment