diff --git a/src/lib.rs b/src/lib.rs index ff1c39af..edeac004 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -111,6 +111,7 @@ use ruma_api::{ Endpoint, Outgoing, }; use ruma_identifiers::DeviceId; +use std::collections::BTreeMap; use url::Url; pub use ruma_client_api as api; @@ -341,6 +342,22 @@ where ) -> impl Future::Incoming, Error>> // We need to duplicate Endpoint's where clauses because the compiler is not smart enough yet. // See https://github.com/rust-lang/rust/issues/54149 + where + Request::Incoming: TryFrom>, Error = FromHttpRequestError>, + ::Incoming: + TryFrom>, Error = FromHttpResponseError>, + { + self.request_with_url_params(request, None) + } + + /// Makes a request to a Matrix API endpoint including additional URL parameters. + pub fn request_with_url_params>( + &self, + request: Request, + params: Option>, + ) -> impl Future::Incoming, Error>> + // We need to duplicate Endpoint's where clauses because the compiler is not smart enough yet. + // See https://github.com/rust-lang/rust/issues/54149 where Request::Incoming: TryFrom>, Error = FromHttpRequestError>, ::Incoming: @@ -359,6 +376,12 @@ where url.set_path(uri.path()); url.set_query(uri.query()); + if let Some(params) = params { + for (key, value) in params { + url.query_pairs_mut().append_pair(&key, &value); + } + } + if Request::METADATA.requires_authentication { if let Some(ref session) = *client.session.lock().unwrap() { url.query_pairs_mut()