Proxy an HTTP request through the plugin's custom fetch. Only valid when `has_custom_fetch()` is true (after a successful `load()`).
(
&self,
request: PluginFetchRequest,
)
| 146 | /// |
| 147 | /// Only valid when `has_custom_fetch()` is true (after a successful `load()`). |
| 148 | pub async fn fetch_proxy( |
| 149 | &self, |
| 150 | request: PluginFetchRequest, |
| 151 | ) -> Result<PluginFetchResponse, PluginAuthError> { |
| 152 | if !self.has_custom_fetch() { |
| 153 | return Err(PluginAuthError::NoCustomFetch( |
| 154 | self.client.name().to_string(), |
| 155 | )); |
| 156 | } |
| 157 | |
| 158 | let result = self |
| 159 | .client |
| 160 | .auth_fetch( |
| 161 | &request.url, |
| 162 | &request.method, |
| 163 | &request.headers, |
| 164 | request.body.as_deref(), |
| 165 | ) |
| 166 | .await?; |
| 167 | |
| 168 | Ok(PluginFetchResponse { |
| 169 | status: result.status, |
| 170 | headers: result.headers, |
| 171 | body: result.body, |
| 172 | }) |
| 173 | } |
| 174 | |
| 175 | /// Proxy an HTTP request through plugin custom fetch as a real-time stream. |
| 176 | pub async fn fetch_proxy_stream( |
no test coverage detected