From f93e77c414011a59ab52895b9d1fac612db45152 Mon Sep 17 00:00:00 2001 From: Gwendal Leclerc Date: Mon, 20 Jul 2026 00:19:40 +0200 Subject: [PATCH] feat(api): return the target session from POST /mocks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The response now includes the session (id + name) the mocks were registered in, so callers — shell scripts especially — can chain GET /mocks?session= without a separate GET /sessions lookup. Additive: the "message" field is unchanged. Session names are not a reliable key (they need not be unique); the opaque id is. Relates to #312. Co-Authored-By: Claude Opus 4.8 --- server/handlers/admin.go | 9 +++++++++ tests/features/set_mocks.yml | 3 +++ 2 files changed, 12 insertions(+) diff --git a/server/handlers/admin.go b/server/handlers/admin.go index e496eb2..936cdcf 100644 --- a/server/handlers/admin.go +++ b/server/handlers/admin.go @@ -78,8 +78,17 @@ func (a *Admin) AddMocks(c echo.Context) error { } } + // Return the target session (id + name) so callers — shell scripts especially — can chain a + // GET /mocks?session= without a separate GET /sessions lookup. Session names are not a + // reliable key (they need not be unique); the opaque id is. + session, err := a.mocksServices.GetSessionByID(sessionID) + if err != nil { + return echo.NewHTTPError(http.StatusInternalServerError, err.Error()) + } + return c.JSON(http.StatusOK, echo.Map{ "message": "Mocks registered successfully", + "session": session.Summarize(), }) } diff --git a/tests/features/set_mocks.yml b/tests/features/set_mocks.yml index 86e21e2..e37d434 100644 --- a/tests/features/set_mocks.yml +++ b/tests/features/set_mocks.yml @@ -12,6 +12,9 @@ testcases: assertions: - result.statuscode ShouldEqual 200 - result.bodyjson.message ShouldEqual "Mocks registered successfully" + # POST /mocks returns the target session so callers can chain GET /mocks?session=. + - result.bodyjson.session.id ShouldNotBeEmpty + - result.bodyjson.session.name ShouldNotBeEmpty - type: http method: GET