It's not possible, also it's not standard and will be hard to parse on client side (if you're using some language with static typing like java).
I think it's much clear to just throw an HttpException in case of error, then you can set both of HTTP Status Code and string error.
Example:
YourStruct YourService::get(int id)
{
auto it = dataStorage.find(id);
NGREST_ASSERT_HTTP(it != storage.end(), HTTP_STATUS_404_NOT_FOUND, "Item not found");
return it->second;
}
пятница, 2 февраля 2018 г., 8:38:08 UTC+3 пользователь Kumar написал: