Skip to content

Commit

Permalink
Updating ClustersHandler::makeRequest to return text response when qu…
Browse files Browse the repository at this point in the history
…ery param parsing fails

Signed-off-by: Demitri Swan <demitriswan@google.com>
  • Loading branch information
miroswan committed May 24, 2024
1 parent 2bba5b4 commit 06785a6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 4 additions & 1 deletion source/server/admin/clusters_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ Http::Code ClustersHandler::handlerClusters(Http::ResponseHeaderMap& response_he
Admin::RequestPtr ClustersHandler::makeRequest(AdminStream& admin_stream) {
Buffer::OwnedImpl response;
ClustersParams params;
params.parse(admin_stream.getRequestHeaders().getPathValue(), response);
Http::Code code = params.parse(admin_stream.getRequestHeaders().getPathValue(), response);
if (code != Http::Code::OK) {
return Admin::makeStaticTextRequest(response, code);
}
return std::make_unique<ClustersRequest>(ClustersRequest::DefaultChunkLimit, server_, params);
}

Expand Down
5 changes: 0 additions & 5 deletions test/server/admin/clusters_params_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,6 @@ struct ParamsCase {

class ParamsFixture : public testing::TestWithParam<ParamsCase> {};

TEST(ClustersParamsTest, ClustersParamsHasExpectedDefaultValue) {
ClustersParams params;
EXPECT_EQ(params.format_, ClustersParams::Format::Text);
}

TEST(ClustersParamsTest, FormatDefaultsToTextWhenNotSupplied) {
ClustersParams params;
Buffer::OwnedImpl buffer;
Expand Down

0 comments on commit 06785a6

Please sign in to comment.