Commit Graph

26 Commits

Author SHA1 Message Date
Wolfgang Bumiller
6488a5cddb api: ApiFutures need to be Send
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
1c1c8530c5 formatting cleanup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
7db28deaff macro: body type support for router and api macros
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
10451f65eb rewrite parse_object
This should support arbitrary expresion, so gobble up
elements up to the next comma and then run it through
syn::parse2.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
1791c089b6 macro: need to allow specifying the body type now
TODO:
  - change parse_object to use Punctuated for the fields to
    support longer value types (so we can use actual types
    as fields)
  - allow adding a body type to methods
  - allow adding a body type to routers explicitly

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
ff2767129f rename reload_timezone -> reload-timezone
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
7d2c13da95 api: add generic Body parameter
Since we already know we'll want to be using hyper::Body and
bytes::Bytes as API output, we need to allow making routers
for each kind.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
b82b14d947 macro: add wildcard matching to router macro
router!{
    /path/{parameter}*: {
        methods...
    }
}

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
8036941977 router: implement 'rest of the path' wildcard matching
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
60df564f73 api: move router to router.rs
We'll have a separate router for the command line, so the
http router won't live in the root module.

It is still exported at the root level, though, via
proxmox::api::Router.

Also move ApiType into api_type.rs, makes more sense.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
dcfa3ca9a2 allow async api methods to return Response<Bytes>
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
3f7e4c0eda router: add remaining missing ::proxmox::api:: prefixes
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
2b577c9c17 cleanup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
1993460d4a allow integer literals as subdirectories
eg: /api/2/ should be legal

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
f3e2e672be use 'quote' in router macro
get rid of a lot of unreadable TokenTree entries

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
7155689724 fix missing proxmox_api -> proxmox::api replacement
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
cd23e0956a macro: switch to using proxmox::api
and fixup a `bail!` -> `::failure::bail!`

Signed-off-by: Wolfgang Bumiller <wry.git@bumiller.com>
2019-06-12 09:48:30 +02:00
Wolfgang Bumiller
024930f63c cargo fmt --all
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-12 09:48:30 +02:00
Dietmar Maurer
71f2d48c2e start proxmox-sys module 2019-06-07 18:03:07 +02:00
Wolfgang Bumiller
3dd6cd3fe0 formatting fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-07 12:03:17 +02:00
Wolfgang Bumiller
b5c05fc85c import proxmox-api-macro crate
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-06 15:25:47 +02:00
Wolfgang Bumiller
671a56c545 typo fixup
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-06 14:47:02 +02:00
Wolfgang Bumiller
5bda38830c Add more documentation
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-06 14:45:05 +02:00
Wolfgang Bumiller
b873e5e2a5 api: router test file
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-06 14:07:26 +02:00
Wolfgang Bumiller
fa2ba562ce add proxmox-api crate
This contains the router and will get helpers for
generating documentation, and for parsing command line
parameters for api methods.

Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-06 14:06:21 +02:00
Wolfgang Bumiller
2e6520a987 initial import, starting with vec & io helpers
Signed-off-by: Wolfgang Bumiller <w.bumiller@proxmox.com>
2019-06-06 14:00:25 +02:00