Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit d9e2c18a authored by raja's avatar raja
Browse files

Implement subscribe function in Notification controller.

parent 13616f90
No related branches found
No related tags found
No related merge requests found
...@@ -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])
}); });
} }
use rocket::response::status::Created; use rocket::response::status::Created;
use rocket::serde::json::Json; 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>>, Error> {
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