Skip to content

Commit 95b3b4d

Browse files
authored
🚧 adding path prefixes so that llm-d deployments are compatible (#523)
Signed-off-by: m-misiura <mmisiura@redhat.com>
1 parent c986e16 commit 95b3b4d

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

src/clients.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,14 @@ pub async fn create_http_client(
212212
.set_port(Some(port))
213213
.unwrap_or_else(|_| panic!("error setting port: {port}"));
214214

215+
// Apply path prefix if configured
216+
if let Some(prefix) = &service_config.path_prefix {
217+
let trimmed = prefix.trim_matches('/');
218+
if !trimmed.is_empty() {
219+
base_url.set_path(&format!("/{}", trimmed));
220+
}
221+
}
222+
215223
let connect_timeout = Duration::from_secs(DEFAULT_CONNECT_TIMEOUT_SEC);
216224
let request_timeout = Duration::from_secs(
217225
service_config

src/clients/http.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ pub struct HttpClient {
125125

126126
impl HttpClient {
127127
pub fn new(base_url: Url, api_token: Option<String>, inner: HttpClientInner) -> Self {
128+
// Ensure base_url has trailing slash for proper path joining
129+
let mut base_url = base_url;
130+
if !base_url.path().ends_with('/') {
131+
base_url.set_path(&format!("{}/", base_url.path()));
132+
}
128133
let health_url = base_url.join("health").unwrap();
129134
Self {
130135
base_url,
@@ -139,6 +144,7 @@ impl HttpClient {
139144
}
140145

141146
pub fn endpoint(&self, path: &str) -> Url {
147+
let path = path.trim_start_matches('/');
142148
self.base_url.join(path).unwrap()
143149
}
144150

src/config.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ pub struct ServiceConfig {
7373
pub hostname: String,
7474
/// Port for service
7575
pub port: Option<u16>,
76+
/// Path prefix for service endpoints (e.g., "/namespace/service-name")
77+
pub path_prefix: Option<String>,
7678
/// Timeout in seconds for request to be handled
7779
pub request_timeout: Option<u64>,
7880
/// TLS provider info
@@ -99,6 +101,7 @@ impl ServiceConfig {
99101
Self {
100102
hostname,
101103
port: Some(port),
104+
path_prefix: None,
102105
request_timeout: None,
103106
tls: None,
104107
grpc_dns_probe_interval: None,

0 commit comments

Comments
 (0)