diff options
author | Wojciech Kępka <46892771+wojciechkepka@users.noreply.github.com> | 2021-02-09 01:22:26 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-08 19:22:26 -0500 |
commit | 5af822c5691a772cad36bd9a69e94419b03d4511 (patch) | |
tree | 761ebc2ac10608a8772d8f7085596ee2ee838b37 /src/transport.rs | |
parent | 4e3f69c34a177697af940849fced1a284fc09449 (diff) |
Add services api (#263)
* Add initial Services models
* Add initial Services controllers
* Add ServicesListOptions
* Rename ServicesList -> ServiceList
* Fix some optional fields on ServiceRep
* Add Service::inspect
* Add Service::delete
* Add Service::logs
* Rename example logs -> containerlogs
* Add ServiceOptions, ServiceCreateInfo, fix typo
* Add a way to pass headers to request, add Payload and Headers for easier
types
* Add Service::create
* Add examples
* Fix fmt
* Fix example
Diffstat (limited to 'src/transport.rs')
-rw-r--r-- | src/transport.rs | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/transport.rs b/src/transport.rs index b496e87..0fbbcc1 100644 --- a/src/transport.rs +++ b/src/transport.rs @@ -30,6 +30,9 @@ pub fn tar() -> Mime { "application/tar".parse().unwrap() } +pub(crate) type Headers = Option<Vec<(&'static str, String)>>; +pub(crate) type Payload = Option<(Body, Mime)>; + /// Transports are types which define the means of communication /// with the docker daemon #[derive(Clone)] @@ -70,18 +73,18 @@ impl fmt::Debug for Transport { impl Transport { /// Make a request and return the whole response in a `String` - pub async fn request<B>( + pub async fn request<'a, B, H>( &self, method: Method, endpoint: impl AsRef<str>, body: Option<(B, Mime)>, + headers: Option<H>, ) -> Result<String> where B: Into<Body>, + H: IntoIterator<Item = (&'static str, String)> + 'a, { - let body = self - .get_body(method, endpoint, body, None::<iter::Empty<_>>) - .await?; + let body = self.get_body(method, endpoint, body, headers).await?; let bytes = hyper::body::to_bytes(body).await?; let string = String::from_utf8(bytes.to_vec())?; |