diff options
author | Alex Auvolat <lx@deuxfleurs.fr> | 2025-01-30 19:08:48 +0100 |
---|---|---|
committer | Alex Auvolat <lx@deuxfleurs.fr> | 2025-02-03 18:54:51 +0100 |
commit | 89ff9f5576f91dc127ba3cc1fae96543e27b9468 (patch) | |
tree | dd6f849031b7ba78a6ca06005918e93bcf3de320 /src/api/admin/special.rs | |
parent | bdaf55ab3f866234bd5a7d585758265a88d2906a (diff) | |
download | garage-89ff9f5576f91dc127ba3cc1fae96543e27b9468.tar.gz garage-89ff9f5576f91dc127ba3cc1fae96543e27b9468.zip |
admin api: base infrastructure for local endpoints
admin api: rename EndpointHandler into RequestHandler to avoid confusion with RPC
wip: infrastructure for local api calls
admin api: fix things
admin api: first local endpoint to work with new scheme
admin api: implement SetWorkerVariable
Diffstat (limited to 'src/api/admin/special.rs')
-rw-r--r-- | src/api/admin/special.rs | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/api/admin/special.rs b/src/api/admin/special.rs index 0b26fe32..4717238d 100644 --- a/src/api/admin/special.rs +++ b/src/api/admin/special.rs @@ -15,13 +15,17 @@ use garage_api_common::helpers::*; use crate::api::{CheckDomainRequest, HealthRequest, OptionsRequest}; use crate::api_server::ResBody; use crate::error::*; -use crate::EndpointHandler; +use crate::{Admin, RequestHandler}; #[async_trait] -impl EndpointHandler for OptionsRequest { +impl RequestHandler for OptionsRequest { type Response = Response<ResBody>; - async fn handle(self, _garage: &Arc<Garage>) -> Result<Response<ResBody>, Error> { + async fn handle( + self, + _garage: &Arc<Garage>, + _admin: &Admin, + ) -> Result<Response<ResBody>, Error> { Ok(Response::builder() .status(StatusCode::OK) .header(ALLOW, "OPTIONS,GET,POST") @@ -33,10 +37,14 @@ impl EndpointHandler for OptionsRequest { } #[async_trait] -impl EndpointHandler for CheckDomainRequest { +impl RequestHandler for CheckDomainRequest { type Response = Response<ResBody>; - async fn handle(self, garage: &Arc<Garage>) -> Result<Response<ResBody>, Error> { + async fn handle( + self, + garage: &Arc<Garage>, + _admin: &Admin, + ) -> Result<Response<ResBody>, Error> { if check_domain(garage, &self.domain).await? { Ok(Response::builder() .status(StatusCode::OK) @@ -103,10 +111,14 @@ async fn check_domain(garage: &Arc<Garage>, domain: &str) -> Result<bool, Error> } #[async_trait] -impl EndpointHandler for HealthRequest { +impl RequestHandler for HealthRequest { type Response = Response<ResBody>; - async fn handle(self, garage: &Arc<Garage>) -> Result<Response<ResBody>, Error> { + async fn handle( + self, + garage: &Arc<Garage>, + _admin: &Admin, + ) -> Result<Response<ResBody>, Error> { let health = garage.system.health(); let (status, status_str) = match health.status { |