MCPcopy Index your code
hub / github.com/NativeScript/SimDeck / metro_proxy_response

Function metro_proxy_response

packages/server/src/api/routes.rs:1278–1323  ·  view source on GitHub ↗
(
    port: u16,
    asset_path: &str,
    query: Option<&str>,
    method: Method,
    headers: HeaderMap,
    body: Bytes,
)

Source from the content-addressed store, hash-verified

1276}
1277
1278async fn metro_proxy_response(
1279 port: u16,
1280 asset_path: &str,
1281 query: Option<&str>,
1282 method: Method,
1283 headers: HeaderMap,
1284 body: Bytes,
1285) -> Response {
1286 let content_type = headers
1287 .get(header::CONTENT_TYPE)
1288 .and_then(|value| value.to_str().ok());
1289 match devtools::fetch_metro_resource(
1290 port,
1291 asset_path,
1292 query,
1293 method.as_str(),
1294 Some(body.as_ref()),
1295 content_type,
1296 )
1297 .await
1298 {
1299 Ok(asset) => {
1300 let status = StatusCode::from_u16(asset.status).unwrap_or(StatusCode::BAD_GATEWAY);
1301 let body = devtools::rewrite_metro_proxy_asset(
1302 port,
1303 asset_path,
1304 asset.content_type.as_deref(),
1305 asset.body,
1306 );
1307 let mut builder = Response::builder()
1308 .status(status)
1309 .header(header::CACHE_CONTROL, "no-store");
1310 if let Some(content_type) = asset.content_type {
1311 builder = builder.header(header::CONTENT_TYPE, content_type);
1312 }
1313 builder
1314 .body(Body::from(body))
1315 .unwrap_or_else(|_| StatusCode::INTERNAL_SERVER_ERROR.into_response())
1316 }
1317 Err(error) => {
1318 tracing::debug!("Metro proxy failed for {port}{asset_path}: {error}");
1319 AppError::not_found("Metro resource is not available through the proxy.")
1320 .into_response()
1321 }
1322 }
1323}
1324
1325async fn webkit_inspector_ui_file(method: Method, uri: Uri) -> Response {
1326 let Some(root) = webkit::webkit_inspector_ui_root() else {

Callers 2

metro_proxy_rootFunction · 0.85
metro_proxy_assetFunction · 0.85

Calls 6

fetch_metro_resourceFunction · 0.85
bodyMethod · 0.80
into_responseMethod · 0.80
getMethod · 0.65
as_strMethod · 0.45

Tested by

no test coverage detected