admin api: fix panic on GetKeyInfo with no args
This commit is contained in:
parent
4f0b923c4f
commit
1c03941b19
1 changed files with 13 additions and 9 deletions
|
@ -43,15 +43,19 @@ impl EndpointHandler for GetKeyInfoRequest {
|
||||||
type Response = GetKeyInfoResponse;
|
type Response = GetKeyInfoResponse;
|
||||||
|
|
||||||
async fn handle(self, garage: &Arc<Garage>) -> Result<GetKeyInfoResponse, Error> {
|
async fn handle(self, garage: &Arc<Garage>) -> Result<GetKeyInfoResponse, Error> {
|
||||||
let key = if let Some(id) = self.id {
|
let key = match (self.id, self.search) {
|
||||||
garage.key_helper().get_existing_key(&id).await?
|
(Some(id), None) => garage.key_helper().get_existing_key(&id).await?,
|
||||||
} else if let Some(search) = self.search {
|
(None, Some(search)) => {
|
||||||
garage
|
garage
|
||||||
.key_helper()
|
.key_helper()
|
||||||
.get_existing_matching_key(&search)
|
.get_existing_matching_key(&search)
|
||||||
.await?
|
.await?
|
||||||
} else {
|
}
|
||||||
unreachable!();
|
_ => {
|
||||||
|
return Err(Error::bad_request(
|
||||||
|
"Either id or search must be provided (but not both)",
|
||||||
|
));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(key_info_results(garage, key, self.show_secret_key).await?)
|
Ok(key_info_results(garage, key, self.show_secret_key).await?)
|
||||||
|
|
Loading…
Add table
Reference in a new issue