仍有bug
This commit is contained in:
@@ -175,11 +175,11 @@ int run_web_server(std::uint16_t port, const std::filesystem::path& asset_root)
|
||||
callback(error_response(drogon::k404NotFound, "unknown plot"));
|
||||
return;
|
||||
}
|
||||
auto output = std::make_shared<std::function<void(const drogon::HttpResponsePtr&)>>(
|
||||
std::move(callback));
|
||||
plot->async_schema([output](nlohmann::json schema) {
|
||||
(*output)(json_response(std::move(schema)));
|
||||
});
|
||||
try { callback(json_response(plot->schema())); }
|
||||
catch (const std::exception& failure) {
|
||||
callback(error_response(drogon::k500InternalServerError,
|
||||
failure.what()));
|
||||
}
|
||||
}, {drogon::Get});
|
||||
|
||||
app.registerHandler("/plot/{1}/component/{2}/prop/{3}", [plots](
|
||||
@@ -200,11 +200,13 @@ int run_web_server(std::uint16_t port, const std::filesystem::path& asset_root)
|
||||
callback(error_response(drogon::k400BadRequest, "invalid JSON value"));
|
||||
return;
|
||||
}
|
||||
auto output = std::make_shared<std::function<void(const drogon::HttpResponsePtr&)>>(
|
||||
std::move(callback));
|
||||
plot->async_write_prop(std::move(component), std::move(key), std::move(value), [output](nlohmann::json result) {
|
||||
(*output)(json_response(std::move(result)));
|
||||
});
|
||||
try {
|
||||
callback(json_response(plot->write_prop(component, key, value)));
|
||||
}
|
||||
catch (const std::exception& failure) {
|
||||
callback(error_response(drogon::k500InternalServerError,
|
||||
failure.what()));
|
||||
}
|
||||
}, {drogon::Put});
|
||||
|
||||
app.registerHandler("/plot/{1}/data/generate", [plots](
|
||||
@@ -227,11 +229,11 @@ int run_web_server(std::uint16_t port, const std::filesystem::path& asset_root)
|
||||
callback(error_response(drogon::k400BadRequest, "data generation input must be an object"));
|
||||
return;
|
||||
}
|
||||
auto output = std::make_shared<std::function<void(const drogon::HttpResponsePtr&)>>(
|
||||
std::move(callback));
|
||||
plot->async_generate_data(std::move(input), [output](nlohmann::json result) {
|
||||
(*output)(json_response(std::move(result)));
|
||||
});
|
||||
try { callback(json_response(plot->generate_data(input))); }
|
||||
catch (const std::exception& failure) {
|
||||
callback(error_response(drogon::k500InternalServerError,
|
||||
failure.what()));
|
||||
}
|
||||
}, {drogon::Post});
|
||||
|
||||
app.registerController(websocket)
|
||||
|
||||
Reference in New Issue
Block a user