Skip to content

Commit be2cf77

Browse files
committed
fix(service): fix url prefixing for subgraphs route
1 parent a7249e2 commit be2cf77

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/service/src/service/router.rs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -383,11 +383,28 @@ impl ServiceRouter {
383383
};
384384

385385
// data layer
386-
let data_routes = Router::new()
387-
.route("/subgraphs/id/{id}", post_request_handler)
386+
let subgraphs_route = Router::new()
387+
.route(
388+
&{
389+
if url_prefix == "/" {
390+
// If prefix is root, just add the route directly
391+
"/subgraphs/id/{id}".to_string()
392+
} else {
393+
// Otherwise, nest it
394+
format!("{}/subgraphs/id/{{id}}", url_prefix)
395+
}
396+
},
397+
post_request_handler,
398+
)
388399
.with_state(graphnode_state.clone());
389400

390-
let subgraphs_route = Router::new().nest(&url_prefix, data_routes);
401+
// let subgraphs_route = if url_prefix == "/" {
402+
// // If prefix is root, just add the route directly
403+
// data_routes.route("/subgraphs/id/{id}", post_request_handler)
404+
// } else {
405+
// // Otherwise, nest it
406+
// data_routes.route(&format!("{}/subgraphs/id/{{id}}", url_prefix), post_request_handler)
407+
// };
391408

392409
let misc_routes = Router::new()
393410
.route("/", get("Service is up and running"))

0 commit comments

Comments
 (0)