diff --git a/catalyst-gateway/bin/src/service/api/fragments/index.rs b/catalyst-gateway/bin/src/service/api/fragments/index.rs new file mode 100644 index 00000000000..871f6ddd266 --- /dev/null +++ b/catalyst-gateway/bin/src/service/api/fragments/index.rs @@ -0,0 +1,27 @@ +//! Implementation of the GET /fragments endpoint + +use poem_extensions::response; +use poem_extensions::UniResponse::T204; + +use crate::service::common::responses::resp_2xx::NoContent; +use crate::service::common::responses::resp_5xx::{ServerError, ServiceUnavailable}; + +/// All responses +pub(crate) type AllResponses = response! { + 204: NoContent, + 500: ServerError, + 503: ServiceUnavailable, +}; + +/// # GET /fragments +/// +/// TODO +/// +/// ## Responses +/// +/// * 204 No Content - Service is OK and can keep running. +/// * 500 Server Error - If anything within this function fails unexpectedly. (Possible but unlikely) +/// * 503 Service Unavailable - Service is possibly not running reliably. +pub(crate) async fn endpoint() -> AllResponses { + T204(NoContent) +} diff --git a/catalyst-gateway/bin/src/service/api/fragments/mod.rs b/catalyst-gateway/bin/src/service/api/fragments/mod.rs new file mode 100644 index 00000000000..c9c78c97133 --- /dev/null +++ b/catalyst-gateway/bin/src/service/api/fragments/mod.rs @@ -0,0 +1,23 @@ +//! Fragment endpoints + +mod index; +mod statuses; + +use crate::service::common::tags::ApiTags; +use poem_openapi::OpenApi; + +/// All Responses +pub(crate) struct FragmentsApi; + +#[OpenApi(prefix_path = "/fragments", tag = "ApiTags::Fragments")] +impl FragmentsApi { + #[oai(path = "/", method = "get", operation_id = "fragments")] + async fn index(&self) -> index::AllResponses { + index::endpoint().await + } + + #[oai(path = "/statuses", method = "get", operation_id = "fragmentsStatuses")] + async fn statuses(&self) -> statuses::AllResponses { + statuses::endpoint().await + } +} diff --git a/catalyst-gateway/bin/src/service/api/fragments/statuses.rs b/catalyst-gateway/bin/src/service/api/fragments/statuses.rs new file mode 100644 index 00000000000..266d61200f9 --- /dev/null +++ b/catalyst-gateway/bin/src/service/api/fragments/statuses.rs @@ -0,0 +1,27 @@ +//! Implementation of the GET /fragments/statuses endpoint + +use poem_extensions::response; +use poem_extensions::UniResponse::T204; + +use crate::service::common::responses::resp_2xx::NoContent; +use crate::service::common::responses::resp_5xx::{ServerError, ServiceUnavailable}; + +/// All responses +pub(crate) type AllResponses = response! { + 204: NoContent, + 500: ServerError, + 503: ServiceUnavailable, +}; + +/// # GET /fragments/statuses +/// +/// TODO +/// +/// ## Responses +/// +/// * 204 No Content - Service is OK and can keep running. +/// * 500 Server Error - If anything within this function fails unexpectedly. (Possible but unlikely) +/// * 503 Service Unavailable - Service is possibly not running reliably. +pub(crate) async fn endpoint() -> AllResponses { + T204(NoContent) +} diff --git a/catalyst-gateway/bin/src/service/api/mod.rs b/catalyst-gateway/bin/src/service/api/mod.rs index c97fb52b9ea..2fd8bf48f3a 100644 --- a/catalyst-gateway/bin/src/service/api/mod.rs +++ b/catalyst-gateway/bin/src/service/api/mod.rs @@ -10,6 +10,9 @@ use v0::V0Api; use crate::settings::API_URL_PREFIX; +use self::fragments::FragmentsApi; + +mod fragments; mod health; mod registration; mod test_endpoints; @@ -58,12 +61,12 @@ fn get_api_license() -> LicenseObject { const TERMS_OF_SERVICE: &str = "https://github.com/input-output-hk/catalyst-core/blob/main/book/src/98_CODE_OF_CONDUCT.md"; +type ApiComponents = (TestApi, HealthApi, V0Api, RegistrationApi, FragmentsApi); + /// Create the `OpenAPI` definition -pub(crate) fn mk_api( - hosts: Vec, -) -> OpenApiService<(TestApi, HealthApi, V0Api, RegistrationApi), ()> { +pub(crate) fn mk_api(hosts: Vec) -> OpenApiService { let mut service = OpenApiService::new( - (TestApi, HealthApi, V0Api, RegistrationApi), + (TestApi, HealthApi, V0Api, RegistrationApi, FragmentsApi), API_TITLE, API_VERSION, ) diff --git a/catalyst-gateway/bin/src/service/common/tags.rs b/catalyst-gateway/bin/src/service/common/tags.rs index 14c20720d0d..6c9dd08b621 100644 --- a/catalyst-gateway/bin/src/service/common/tags.rs +++ b/catalyst-gateway/bin/src/service/common/tags.rs @@ -4,6 +4,8 @@ use poem_openapi::Tags; /// `OpenAPI` Tags #[derive(Tags)] pub(crate) enum ApiTags { + /// Fragment endpoints + Fragments, /// Health Endpoints Health, /// Information relating to Voter Registration, Delegations and Calculated Voting