Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit 18b337e7 authored by DawnFall19's avatar DawnFall19
Browse files

Implement unsubscribe function in Notification controller.

parent ac2459c6
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 reqwest::Url;
use rocket::response::status::Created;
use rocket::serde::json::Json;
......@@ -14,4 +15,12 @@ pub fn subscribe(product_type: &str, subscriber: Json<Subscriber>) -> Result<Cre
Ok(f) => Ok(Created::new("/").body(Json::from(f))),
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)
};
}
\ 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