#[cfg(feature = "http_attohttpc")]
use attohttpc;
use handlebars::{handlebars_helper, Handlebars};
#[cfg(all(feature = "http_reqwest", not(feature = "http_attohttpc")))]
use reqwest;
#[cfg(feature = "http_attohttpc")]
fn http_get_fct<T: AsRef<str>>(url: T) -> Result<String, attohttpc::Error> {
attohttpc::get(url.as_ref()).send()?.text()
}
#[cfg(all(feature = "http_reqwest", not(feature = "http_attohttpc")))]
fn http_get_fct<T: AsRef<str>>(url: T) -> Result<String, reqwest::Error> {
reqwest::blocking::get(url.as_ref())?.text()
}
#[cfg(any(feature = "http_reqwest", feature = "http_attohttpc"))]
pub fn register(handlebars: &mut Handlebars) {
{
handlebars_helper!(http_get: |v: str| http_get_fct(v).map_err(crate::to_nested_error)?);
handlebars.register_helper("http_get", Box::new(http_get))
}
{
handlebars_helper!(gitignore_io: |v: str| http_get_fct(format!("https://www.gitignore.io/api/{}", v)).map_err(crate::to_nested_error)?);
handlebars.register_helper("gitignore_io", Box::new(gitignore_io))
}
}