mrml_wasm/parser/
reqwest_include_loader.rs1use std::collections::HashMap;
2
3use mrml::prelude::parser::http_loader::{AsyncReqwestFetcher, HttpIncludeLoader};
4use mrml::prelude::parser::loader::AsyncIncludeLoader;
5
6#[derive(Clone, Debug, Default, serde::Deserialize, serde::Serialize, tsify::Tsify)]
7pub struct ReqwestIncludeLoaderOptions {
8 pub headers: HashMap<String, String>,
9}
10
11impl ReqwestIncludeLoaderOptions {
12 pub fn new(headers: HashMap<String, String>) -> Self {
13 Self { headers }
14 }
15
16 pub fn build_async(self) -> Box<dyn AsyncIncludeLoader + Sync + Send + 'static> {
17 Box::new(HttpIncludeLoader::<AsyncReqwestFetcher>::allow_all().with_headers(self.headers))
18 }
19}