http: a route's captures replace those the request already carries

Router::dispatch put a route's captures into the request with std::map::insert, which keeps a key
the request already has. The front matches /v1/models/ID itself and hands the request to the
model's router with the path rewritten, an alias as the model's name and base:adapter as the
adapter's, so the model read the front's id: through the front, GET /v1/models/ALIAS and
GET /v1/models/base:adapter answered 404. The captures of the route that matched now replace those
of the same name; nothing sets a request's params before a dispatch otherwise.

server_test: a_request_handed_on_reads_the_capture_of_the_route_that_matched_it fails without the
change and passes with it.
This commit is contained in:
keptn42 authored and StillDeadcode committed 2026-11-16 17:57:46 +01:00
1 parent b27f352259
commit aadabde0de
2 files changed
+20 -1

No files matched your search

+14
View File
@@ -2694,6 +2694,20 @@ TEST(the_adaptive_draft_window_is_exposed_only_while_it_is_on) {
CHECK_NEAR(value("radiance:draft_verify_depth_total" + L + ",depth=\"6\"}"), -1.0, 1e-9);
}
/* The front matches /v1/models/ID itself and hands the request on with the path rewritten: an
* alias becomes the model's name, `base:adapter` the adapter's. The model's router reads the id its
* own route captured, not the front's, so the request still carries the front's capture here. */
TEST(a_request_handed_on_reads_the_capture_of_the_route_that_matched_it) {
Fixture f;
HttpRequest q;
q.method = "GET";
q.path = "/v1/models/test-model";
q.params["id"] = "an-alias";
const HttpResponse r = f.srv->router().dispatch(q);
CHECK_EQ(r.status, 200);
CHECK_EQ(json::parse(r.body).value("id", std::string()), std::string("test-model"));
}
TEST(models_and_health_answer) {
Fixture f;
HttpResponse r = f.get("/v1/models");