teloxide/src/bot/api_url.rs
Waffle f4e3aa13eb Add Bot::{set_,}api_url methods
The methods allow to set and get the Telegram bot API url.
2020-12-28 18:45:45 +03:00

18 lines
448 B
Rust

use std::sync::Arc;
#[derive(Debug, Clone)]
pub(crate) enum ApiUrl {
Default,
Custom(Arc<reqwest::Url>),
}
impl ApiUrl {
pub(crate) fn get(&self) -> reqwest::Url {
match self {
// FIXME(waffle): parse once
ApiUrl::Default => reqwest::Url::parse(crate::net::TELEGRAM_API_URL)
.expect("failed to parse default url"),
ApiUrl::Custom(url) => (&**url).clone(),
}
}
}