#pragma once // Spec: models.md ActionResponse. Generic helper: ok, redirect required, data optional. #include #include #include "core/JsonDecode.hpp" namespace dp { struct EmptyActionPayload { static EmptyActionPayload fromJson(const Json&) { return {}; } // accepts any JSON }; template struct ActionResponse { bool ok = false; std::string redirect; std::optional data; static ActionResponse fromJson(const Json& j) { ActionResponse r; r.ok = JsonDecode::req(j, "ok"); r.redirect = JsonDecode::req(j, "redirect"); if (const Json* d = JsonRead::child(j, "data")) r.data = Payload::fromJson(*d); return r; } }; } // namespace dp