diff --git a/src/controller/mod.rs b/src/controller/mod.rs index b1d8df3d48fedcaf5843728fe18632a21cb8d6db..57802940cd1c6898709b20e9aad9e4d9b2b2be04 100644 --- a/src/controller/mod.rs +++ b/src/controller/mod.rs @@ -6,6 +6,7 @@ pub fn route_stage() -> AdHoc { return AdHoc::on_ignite("Initializing controller routes...", |rocket| async { rocket .mount("/", routes![notification::subscribe, notification::unsubscribe, - notification::receive]) + notification::receive, + notification::list]) }); } diff --git a/src/controller/notification.rs b/src/controller/notification.rs index 06ab9dacc6140488691b4170b51fa2d5663fe76d..6cfb26aa263ec76b4971151a63b21205b5fa391c 100644 --- a/src/controller/notification.rs +++ b/src/controller/notification.rs @@ -27,4 +27,12 @@ pub fn receive(notification: Json<Notification>) -> Result<Json<Notification>> { Ok(f) => Ok(Json::from(f)), 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 diff --git a/src/service/notification.rs b/src/service/notification.rs index 35ae56baadf1cf6b75985b0731fa29ab7248f9d4..37a069854fa021f7211b4186d75e3dfc2f725cc5 100644 --- a/src/service/notification.rs +++ b/src/service/notification.rs @@ -91,4 +91,9 @@ use rocket::http::Status; let subscriber_result = NotificationRepository::add(payload.clone()); return Ok(subscriber_result); } + + + pub fn list_messages() -> Result<Vec<String>> { + return Ok(NotificationRepository::list_all_as_string()); + } } \ No newline at end of file