Fakultas Ilmu Komputer UI

Skip to content
Snippets Groups Projects
Commit 5da81353 authored by Andrew4Coding's avatar Andrew4Coding
Browse files

Implement list function in Notification controller.

parent 18c1595d
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,6 @@ use rocket::fairing::AdHoc; ...@@ -4,6 +4,6 @@ use rocket::fairing::AdHoc;
pub fn route_stage() -> AdHoc { 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("/", routes![notification::subscribe, notification::unsubscribe, notification::receive]) .mount("/", routes![notification::subscribe, notification::unsubscribe, notification::receive, notification::list])
}); });
} }
...@@ -27,4 +27,12 @@ pub fn receive(notification: Json<Notification>) -> Result<Json<Notification>> { ...@@ -27,4 +27,12 @@ pub fn receive(notification: Json<Notification>) -> Result<Json<Notification>> {
Ok(f) => Ok(Json::from(f)), Ok(f) => Ok(Json::from(f)),
Err(e) => Err(e) Err(e) => Err(e)
} }
}
#[get("/")]
pub fn list() -> Result<Json<Vec<String>>> {
return match NotificationService::list_messages() {
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.
Please register or to comment