diff --git a/api/storage_service.cc b/api/storage_service.cc index 8964349c75..82835c9b70 100644 --- a/api/storage_service.cc +++ b/api/storage_service.cc @@ -983,40 +983,38 @@ void set_storage_service(http_context& ctx, routes& r) { void set_snapshot(http_context& ctx, routes& r, sharded& snap_ctl) { ss::get_snapshot_details.set(r, [&snap_ctl](std::unique_ptr req) { return snap_ctl.local().get_snapshot_details().then([] (std::unordered_map>&& result) { - return do_with(std::move(result), [](const std::unordered_map>& result) { - std::function(output_stream&&)> f = [&result](output_stream&& s) { - return do_with(output_stream(std::move(s)), true, [&result] (output_stream& s, bool& first){ - return s.write("[").then([&s, &first, &result] { - return do_for_each(result, [&s, &result, &first](std::tuple>&& map){ - return do_with(ss::snapshots(), [&s, &first, &map](ss::snapshots& all_snapshots) { - all_snapshots.key = std::get<0>(map); - future<> f = first ? make_ready_future<>() : s.write(", "); - first = false; - std::vector snapshot; - for (auto& cf: std::get<1>(map)) { - ss::snapshot snp; - snp.ks = cf.ks; - snp.cf = cf.cf; - snp.live = cf.live; - snp.total = cf.total; - snapshot.push_back(std::move(snp)); - } - all_snapshots.value = std::move(snapshot); - return f.then([&s, &all_snapshots] { - return all_snapshots.write(s); - }); + std::function(output_stream&&)> f = [result = std::move(result)](output_stream&& s) { + return do_with(output_stream(std::move(s)), true, [&result] (output_stream& s, bool& first){ + return s.write("[").then([&s, &first, &result] { + return do_for_each(result, [&s, &first](std::tuple>&& map){ + return do_with(ss::snapshots(), [&s, &first, &map](ss::snapshots& all_snapshots) { + all_snapshots.key = std::get<0>(map); + future<> f = first ? make_ready_future<>() : s.write(", "); + first = false; + std::vector snapshot; + for (auto& cf: std::get<1>(map)) { + ss::snapshot snp; + snp.ks = cf.ks; + snp.cf = cf.cf; + snp.live = cf.live; + snp.total = cf.total; + snapshot.push_back(std::move(snp)); + } + all_snapshots.value = std::move(snapshot); + return f.then([&s, &all_snapshots] { + return all_snapshots.write(s); }); }); - }).then([&s] { - return s.write("]").then([&s] { - return s.close(); - }); + }); + }).then([&s] { + return s.write("]").then([&s] { + return s.close(); }); }); - }; + }); + }; - return make_ready_future(std::move(f)); - }); + return make_ready_future(std::move(f)); }); });