diff --git a/src/controller/mod.rs b/src/controller/mod.rs index b6d9501fe32101db8245529f1f151a46339e2d92..d7447fb4c312a1cc7d24f19f8e0d9b02bfaf768d 100644 --- a/src/controller/mod.rs +++ b/src/controller/mod.rs @@ -8,7 +8,8 @@ pub fn route_stage() -> AdHoc { routes![ notification::subscribe, notification::unsubscribe, - notification::receive + notification::receive, + notification::list, ], ) }); diff --git a/src/controller/notification.rs b/src/controller/notification.rs index 18af25485aa0b1e48c1d0f11c5eed162a336e5e0..791043af7007f1daa3a8391a9be7a38fca6578a4 100644 --- a/src/controller/notification.rs +++ b/src/controller/notification.rs @@ -28,3 +28,11 @@ pub fn receive(notification: Json<Notification>) -> Result<Json<Notification>> { Err(e) => Err(e), }; } + +#[get("/")] +pub fn list() -> Result<Json<Vec<Notification>>> { + return match NotificationService::list_messages() { + Ok(f) => Ok(Json::from(f)), + Err(e) => Err(e), + }; +} diff --git a/src/service/notification.rs b/src/service/notification.rs index ae2845b738e9842c54e239bef09f798015b681df..14b1f0adeae9ab64536fc6a6120d45c106c2e359 100644 --- a/src/service/notification.rs +++ b/src/service/notification.rs @@ -99,7 +99,7 @@ impl NotificationService { return Ok(subscriber_result); } - pub fn list messages() -> Result<Vec<String>> { + pub fn list_messages() -> Result<Vec<String>> { return Ok(NotificationRepository::list_all_as_string()); } }