diff options
author | Ed Tanous <ed.tanous@intel.com> | 2018-09-21 23:38:49 +0300 |
---|---|---|
committer | Ed Tanous <ed.tanous@intel.com> | 2018-10-22 19:04:10 +0300 |
commit | 9712f8ac42746e65f32c2bc3de0835846652568e (patch) | |
tree | 779224bc1c29105e0228626ea7335b610e266ddc /src/security_headers_middleware_test.cpp | |
parent | 820ce598b31a6f9bf4d3715d337b8e5ee47196c7 (diff) | |
download | bmcweb-9712f8ac42746e65f32c2bc3de0835846652568e.tar.xz |
Implement a new way of unpacking json to structs
The existing way of decoding json structures, while fast has some disadvantages.
1. it's very verbose to write.
2. It requires in depth knowlege of redfish error messages to get
correct.
3. It _can_ lead to undesired behavior, like half of a patch being
applied, if only some of the values have bad types.
This commit implements a new interface for decoding redfish json
named.... readJson. It is a templated function, that lets you decode
json values based on type easily, while still handling all the correct
error codes that were handled previously. Use is done similar to the
example below:
std::string required;
boost::optional<std::string> optional;
if (!json_util::readJson(req, res, "OptionalParam", optional,
"RequiredParam", required))
{
return;
}
if (optional){
// optional param was given, take action.
}
As part of this patchset, the systems schema is moved to the new
interface, which deletes some of the code involved and shows the
improvement in clarity.
Change-Id: I041a97c84d294df8cd4de4c2702e5ee22c0bc120
Signed-off-by: Ed Tanous <ed.tanous@intel.com>
Diffstat (limited to 'src/security_headers_middleware_test.cpp')
0 files changed, 0 insertions, 0 deletions