fix incorrect json responses

This commit is contained in:
Theis Pieter Hollebeek 2024-12-12 11:33:38 +01:00
parent 803230840b
commit 90287512e4

View File

@ -7,6 +7,8 @@ auto sliger::rpc::action::RunDebug::perform_action(
{ {
auto program = this->instructions; auto program = this->instructions;
vm.load_and_run(program); vm.load_and_run(program);
writer->write("{ \"ok\": true }");
writer->flush();
}; };
auto sliger::rpc::action::FlameGraph::perform_action( auto sliger::rpc::action::FlameGraph::perform_action(
@ -15,10 +17,10 @@ auto sliger::rpc::action::FlameGraph::perform_action(
{ {
auto json = vm.flame_graph_json(); auto json = vm.flame_graph_json();
if (json) { if (json) {
writer->write( writer->write(std::format(
std::format("{{ ok: true, flameGraph: \"{}\" }}", json.value())); "{{ \"ok\": true, \"flameGraph\": \"{}\" }}", json.value()));
} else { } else {
writer->write("null"); writer->write("{ \"ok\": false }");
} }
writer->flush(); writer->flush();
}; };
@ -29,10 +31,10 @@ auto sliger::rpc::action::CodeCoverage::perform_action(
{ {
auto json = vm.code_coverage_json(); auto json = vm.code_coverage_json();
if (json) { if (json) {
writer->write( writer->write(std::format(
std::format("{{ ok: true, codeCoverage: \"{}\" }}", json.value())); "{{ \"ok\": true, \"codeCoverage\": \"{}\" }}", json.value()));
} else { } else {
writer->write("{ ok: false }"); writer->write("{ \"ok\": false }");
} }
writer->flush(); writer->flush();
}; };