]>
git.proxmox.com Git - proxmox-backup.git/blob - src/api_info.rs
4 use serde_json
::{Value}
;
6 pub struct ApiMethod
<'a
> {
7 pub description
: &'a
str,
8 pub properties
: &'a PropertyMap
<'a
>,
9 pub returns
: &'a Jss
<'a
>,
10 pub handler
: fn(Value
) -> Result
<Value
, Error
>,
13 pub type SubdirMap
<'a
> = crate::static_map
::StaticMap
<'a
, &'a
str, &'a MethodInfo
<'a
>>;
15 pub struct MethodInfo
<'a
> {
16 pub get
: Option
<&'a ApiMethod
<'a
>>,
17 pub put
: Option
<&'a ApiMethod
<'a
>>,
18 pub post
: Option
<&'a ApiMethod
<'a
>>,
19 pub delete
: Option
<&'a ApiMethod
<'a
>>,
20 pub subdirs
: Option
<&'a SubdirMap
<'a
>>,
23 pub static METHOD_INFO_DEFAULTS
: MethodInfo
= MethodInfo
{
31 pub fn find_method_info
<'a
>(root
: &'a MethodInfo
, components
: &[&str]) -> Option
<&'a MethodInfo
<'a
>> {
33 if components
.len() == 0 { return Some(root); }
;
35 let (dir
, rest
) = (components
[0], &components
[1..]);
37 if let Some(ref dirmap
) = root
.subdirs
{
38 if let Some(info
) = dirmap
.get(&dir
) {
39 return find_method_info(info
, rest
);