Skip to content
This repository was archived by the owner on Apr 12, 2025. It is now read-only.

Commit 88d91b2

Browse files
committed
fix: xml
1 parent 2fbde36 commit 88d91b2

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ run:
3333
REPLEX_ENABLE_CONSOLE=0 \
3434
REPLEX_CACHE_TTL=0 \
3535
REPLEX_HUB_RESTRICTIONS=1 \
36-
RUST_LOG="info,replex=info,replex::transform=debug" \
36+
RUST_LOG="info,replex=debug,replex::transform=debug" \
3737
REPLEX_NTF_WATCHLIST_FORCE=0 \
3838
RUSTFLAGS=-Awarnings \
3939
cargo watch -w src -x run

src/routes.rs

+24-5
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ use salvo::http::header::CONTENT_TYPE;
1414
use salvo::http::{Request, Response, StatusCode};
1515
use salvo::prelude::*;
1616
use salvo::routing::PathFilter;
17+
use salvo::http::HeaderValue;
18+
use salvo::http::header;
1719
use tokio::time::Duration;
1820
use url::Url;
1921
use http;
@@ -128,7 +130,7 @@ pub fn route() -> Router {
128130
.hoop(transform_req_content_directory)
129131
.hoop(transform_req_include_guids)
130132
.hoop(transform_req_android)
131-
.hoop(proxy_request)
133+
.hoop(proxy_for_transform)
132134
.get(transform_hubs_response),
133135
)
134136
.push(
@@ -141,7 +143,7 @@ pub fn route() -> Router {
141143
.path(format!("{}/<id>", PLEX_HUBS_SECTIONS))
142144
.hoop(transform_req_include_guids)
143145
.hoop(transform_req_android)
144-
.hoop(proxy_request)
146+
.hoop(proxy_for_transform)
145147
.get(transform_hubs_response)
146148
)
147149
.push(
@@ -187,6 +189,23 @@ async fn proxy_request(
187189
proxy.handle(req, depot, res, ctrl).await;
188190
}
189191

192+
#[handler]
193+
async fn proxy_for_transform(
194+
req: &mut Request,
195+
res: &mut Response,
196+
depot: &mut Depot,
197+
ctrl: &mut FlowCtrl,
198+
) -> Result<(), anyhow::Error> {
199+
let config: Config = Config::dynamic(req).extract().unwrap();
200+
let content_type = get_content_type_from_headers(req.headers_mut());
201+
let proxy = default_proxy();
202+
let headers_ori = req.headers().clone();
203+
req.headers_mut().insert(http::header::ACCEPT, header::HeaderValue::from_static("application/json"));
204+
proxy.handle(req, depot, res, ctrl).await;
205+
*req.headers_mut() = headers_ori;
206+
Ok(())
207+
}
208+
190209
// skip processing when product is plexamp
191210
#[handler]
192211
async fn should_skip(
@@ -534,11 +553,12 @@ pub async fn transform_hubs_response(
534553
let params: PlexContext = req.extract().await.unwrap();
535554
let plex_client = PlexClient::from_request(req, params.clone());
536555
let content_type = get_content_type_from_headers(req.headers_mut());
537-
556+
dbg!(&res);
557+
dbg!(&req);
538558
let mut container: MediaContainerWrapper<MediaContainer> =
539559
from_salvo_response(res).await?;
540560
container.content_type = content_type;
541-
561+
dbg!("GO");
542562
TransformBuilder::new(plex_client, params.clone())
543563
.with_filter(HubRestrictionFilter)
544564
.with_transform(HubStyleTransform { is_home: true })
@@ -735,7 +755,6 @@ pub async fn default_transform(
735755
let mut container: MediaContainerWrapper<MediaContainer> =
736756
from_reqwest_response(upstream_res).await?;
737757
container.content_type = content_type;
738-
// container.media_container.meta
739758

740759
TransformBuilder::new(plex_client, params.clone())
741760
.with_filter(HubRestrictionFilter)

0 commit comments

Comments
 (0)