Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit d6d9694a authored by lantry-glitch's avatar lantry-glitch
Browse files

Implement subscribe function in Notification controller.

parent 7e87f9da
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])
});
}
......@@ -4,3 +4,11 @@ use rocket::serde::json::Json;
use bambangshop::Result;
use crate::model::subscriber::Subscriber;
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)
};
}
pub mod product;
pub mod subscriber;
pub mod notification;
pub mod notification;
\ 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