rest-server: more convenient alias-list for ApiConfig

To the existing `.alias(item)`, add a
`.aliases(into-item-iter)` similar to how `Extend` works.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
This commit is contained in:
Wolfgang Bumiller 2023-01-26 09:41:06 +01:00
parent 310310c650
commit 2f2f5cfcd8

View File

@ -146,6 +146,18 @@ impl ApiConfig {
self
}
/// Register multiple path aliases. See `[ApiConfig::alias()]`.
pub fn aliases<I, S, P>(mut self, aliases: I) -> Self
where
I: IntoIterator<Item = (S, P)>,
S: Into<String>,
P: Into<PathBuf>,
{
self.aliases
.extend(aliases.into_iter().map(|(s, p)| (s.into(), p.into())));
self
}
pub(crate) fn env_type(&self) -> RpcEnvironmentType {
self.env_type
}