Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit 4b1b3429 authored by rafliesa's avatar rafliesa
Browse files

Implement unsubscribe function in Notification controller.

parent 232b2df9
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![notification::subscribe])
.mount("notification", routes![notification::subscribe, notification::unsubscribe])
});
}
use rocket::response::status::Created;
use rocket::serde::json::Json;
use rocket::serde::json::{self, Json};
use bambangshop::Result;
use crate::model::subscriber::{self, Subscriber};
......@@ -12,3 +12,11 @@ pub fn subscribe(product_type: &str, subscriber: Json<Subscriber>) -> Result<Cre
Err(e) => Err(e)
}
}
#[post("/unsubscribe/<product_type>?<url>")]
pub fn unsubscribe(product_type: &str, url: &str) -> Result<Json<Subscriber>> {
return match NotificationService::unsubscribe(product_type, url) {
Ok(f) => Ok(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