comparison Plugins/Samples/Common/OrthancPluginConnection.cpp @ 2183:1d0838b8e9c5

RestApiDelete and RestApiPut
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 25 Nov 2016 21:33:35 +0100
parents de32f3b4ff09
children 403d92d8df83
comparison
equal deleted inserted replaced
2182:085a41c66133 2183:1d0838b8e9c5
56 const std::string& uri, 56 const std::string& uri,
57 const std::string& body) 57 const std::string& body)
58 { 58 {
59 OrthancPlugins::MemoryBuffer buffer(context_); 59 OrthancPlugins::MemoryBuffer buffer(context_);
60 60
61 if (!buffer.RestApiPost(uri, body.c_str(), body.size(), false)) 61 if (buffer.RestApiPost(uri, body.c_str(), body.size(), false))
62 { 62 {
63 buffer.ToString(result); 63 buffer.ToString(result);
64 } 64 }
65 else 65 else
66 { 66 {
67 ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_UnknownResource); 67 ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_UnknownResource);
68 } 68 }
69 } 69 }
70
71
72 void OrthancPluginConnection::RestApiPut(std::string& result,
73 const std::string& uri,
74 const std::string& body)
75 {
76 OrthancPlugins::MemoryBuffer buffer(context_);
77
78 if (buffer.RestApiPut(uri, body.c_str(), body.size(), false))
79 {
80 buffer.ToString(result);
81 }
82 else
83 {
84 ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_UnknownResource);
85 }
86 }
87
88
89 void OrthancPluginConnection::RestApiDelete(const std::string& uri)
90 {
91 OrthancPlugins::MemoryBuffer buffer(context_);
92
93 if (!::OrthancPlugins::RestApiDelete(context_, uri, false))
94 {
95 ORTHANC_PLUGINS_THROW_EXCEPTION(OrthancPluginErrorCode_UnknownResource);
96 }
97 }
70 } 98 }