diff --git a/include/data.hpp b/include/data.hpp index 3328d67..1219826 100644 --- a/include/data.hpp +++ b/include/data.hpp @@ -8,6 +8,7 @@ class data : public json { fs::path &get_data_path(); void create_data_directory(); fs::path get_store_path(); + bool validate(const json &); public: data(); diff --git a/src/data.cpp b/src/data.cpp index 55fe337..dd21cf0 100644 --- a/src/data.cpp +++ b/src/data.cpp @@ -42,6 +42,12 @@ void data::create_data_directory() { fs::path data::get_store_path() { return get_data_path() / "store.json"; } -nlohmann::json data::process(const nlohmann::json &) { +json data::process(const json &input) { + if (!validate(input)) { + return nullptr; + } + return {{"success", true}}; -} \ No newline at end of file +} + +bool data::validate(const json &input) {} diff --git a/src/store.cpp b/src/store.cpp index 5f1950e..e9a2776 100644 --- a/src/store.cpp +++ b/src/store.cpp @@ -80,8 +80,11 @@ int Application::run() { const auto json_response = dat.process(data); - response->write(Status::client_error_precondition_required, - json_response.dump(), + if (json_response.is_null()) { + return response::bad_object(response); + } + + response->write(Status::success_created, json_response.dump(), {header_access_control, header_application_data}); };