Refine core/network/mod.rs
@@ -8,7 +8,9 @@ use crate::core::requests::{RequestError, ResponseResult};
const TELEGRAM_API_URL: &str = "https://api.telegram.org";
-/// Create url for macking requests, see [telegram docs](https://core.telegram.org/bots/api#making-requests)
+/// Creates URL for making HTTPS requests. See the [Telegram documentation].
+///
+/// [Telegram documentation]: https://core.telegram.org/bots/api#making-requests
fn method_url(base: &str, token: &str, method_name: &str) -> String {
format!(
"{url}/bot{token}/{method}",
@@ -18,7 +20,9 @@ fn method_url(base: &str, token: &str, method_name: &str) -> String {
)
}
-/// Create url for downloading file, see [telegram docs](https://core.telegram.org/bots/api#file)
+/// Creates URL for downloading a file. See the [Telegram documentation].
+///
+/// [Telegram documentation] (https://core.telegram.org/bots/api#file)
fn file_url(base: &str, token: &str, file_path: &str) -> String {
format!(
"{url}/file/bot{token}/{file}",
@@ -37,11 +41,10 @@ pub async fn request<T: DeserializeOwned>(
let mut response = client
.post(&method_url(TELEGRAM_API_URL, token, method_name))
.apply(|request_builder| {
- if let Some(params) = params {
- request_builder.multipart(params)
- } else {
- request_builder
- }
+ params.map_or_else(
+ || request_builder,
+ |params| request_builder.multipart(params),
+ )
})
.send()
.compat()
