Browse Source

add validation

master
Jørgen Sverre Lien Sellæg 5 years ago
parent
commit
b5f0866471
  1. 1
      include/data.hpp
  2. 8
      src/data.cpp
  3. 7
      src/store.cpp

1
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();

8
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}};
}
bool data::validate(const json &input) {}

7
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});
};

Loading…
Cancel
Save