REST: Add JSON error when no D-Bus handlers found
Add the full JSON error response for the case when
the URL looks like it should correspond to a D-Bus
operation, but doesn't.
Change-Id: I63a2c05fd8ab3adcdd81d407f9359ebb0279cdc3
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/include/openbmc_dbus_rest.hpp b/include/openbmc_dbus_rest.hpp
index dfa618f..c8811a6 100644
--- a/include/openbmc_dbus_rest.hpp
+++ b/include/openbmc_dbus_rest.hpp
@@ -36,12 +36,14 @@
const std::string notFoundMsg = "404 Not Found";
const std::string badReqMsg = "400 Bad Request";
+const std::string methodNotAllowedMsg = "405 Method Not Allowed";
const std::string notFoundDesc =
"org.freedesktop.DBus.Error.FileNotFound: path or object not found";
const std::string propNotFoundDesc = "The specified property cannot be found";
const std::string noJsonDesc = "No JSON object could be decoded";
const std::string methodNotFoundDesc = "The specified method cannot be found";
+const std::string methodNotAllowedDesc = "Method not allowed";
void setErrorResponse(crow::Response &res, boost::beast::http::status result,
const std::string &desc, const std::string &msg)
@@ -1379,7 +1381,8 @@
return;
}
- res.result(boost::beast::http::status::method_not_allowed);
+ setErrorResponse(res, boost::beast::http::status::method_not_allowed,
+ methodNotAllowedDesc, methodNotAllowedMsg);
res.end();
}