admin api: small fixes

This commit is contained in:
Alex Auvolat
2025-01-29 12:06:58 +01:00
parent 420bbc162d
commit 4f0b923c4f
6 changed files with 41 additions and 10 deletions
+18 -1
View File
@@ -14,7 +14,7 @@ macro_rules! admin_endpoints {
)*
}
#[derive(Serialize, Deserialize)]
#[derive(Serialize)]
#[serde(untagged)]
pub enum AdminApiResponse {
$(
@@ -22,6 +22,13 @@ macro_rules! admin_endpoints {
)*
}
#[derive(Serialize, Deserialize)]
pub enum TaggedAdminApiResponse {
$(
$endpoint( [<$endpoint Response>] ),
)*
}
impl AdminApiRequest {
pub fn name(&self) -> &'static str {
match self {
@@ -35,6 +42,16 @@ macro_rules! admin_endpoints {
}
}
impl AdminApiResponse {
fn tagged(self) -> TaggedAdminApiResponse {
match self {
$(
Self::$endpoint(res) => TaggedAdminApiResponse::$endpoint(res),
)*
}
}
}
#[async_trait]
impl EndpointHandler for AdminApiRequest {
type Response = AdminApiResponse;