Build a new URI with a rewritten path, preserving query string. Incoming axum URIs are path-only (no scheme/authority), so we build path-only too.
(original: &Uri, new_path: &str)
| 1073 | /// Build a new URI with a rewritten path, preserving query string. |
| 1074 | /// Incoming axum URIs are path-only (no scheme/authority), so we build path-only too. |
| 1075 | fn build_rewritten_uri(original: &Uri, new_path: &str) -> Result<Uri, String> { |
| 1076 | let path_and_query = if let Some(query) = original.query() { |
| 1077 | format!("{new_path}?{query}") |
| 1078 | } else { |
| 1079 | new_path.to_string() |
| 1080 | }; |
| 1081 | path_and_query |
| 1082 | .parse::<Uri>() |
| 1083 | .map_err(|e| format!("failed to build rewritten URI: {e}")) |
| 1084 | } |
| 1085 | |
| 1086 | fn ensure_stream_options(body: &[u8], provider: Provider) -> Option<Vec<u8>> { |
| 1087 | if !matches!(provider, Provider::Openai | Provider::Openrouter) { |
no outgoing calls
no test coverage detected