Mercurial > hg > orthanc
comparison Plugins/Samples/ServeFolders/Plugin.cpp @ 1628:77c4cc4def0f
OrthancPluginErrorCode in REST callbacks
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Fri, 18 Sep 2015 16:46:35 +0200 |
parents | 415dfd1d1c61 |
children | b1291df2f780 |
comparison
equal
deleted
inserted
replaced
1627:da7854deb662 | 1628:77c4cc4def0f |
---|---|
154 return true; | 154 return true; |
155 } | 155 } |
156 } | 156 } |
157 | 157 |
158 | 158 |
159 static int32_t FolderCallback(OrthancPluginRestOutput* output, | 159 static OrthancPluginErrorCode FolderCallback(OrthancPluginRestOutput* output, |
160 const char* url, | 160 const char* url, |
161 const OrthancPluginHttpRequest* request) | 161 const OrthancPluginHttpRequest* request) |
162 { | 162 { |
163 namespace fs = boost::filesystem; | 163 namespace fs = boost::filesystem; |
164 | 164 |
165 if (request->method != OrthancPluginHttpMethod_Get) | 165 if (request->method != OrthancPluginHttpMethod_Get) |
166 { | 166 { |
167 OrthancPluginSendMethodNotAllowed(context_, output, "GET"); | 167 OrthancPluginSendMethodNotAllowed(context_, output, "GET"); |
168 return 0; | 168 return OrthancPluginErrorCode_Success; |
169 } | 169 } |
170 | 170 |
171 std::string folder; | 171 std::string folder; |
172 | 172 |
173 if (LookupFolder(folder, output, request)) | 173 if (LookupFolder(folder, output, request)) |
229 OrthancPluginSendHttpStatusCode(context_, output, 404); | 229 OrthancPluginSendHttpStatusCode(context_, output, 404); |
230 } | 230 } |
231 } | 231 } |
232 } | 232 } |
233 | 233 |
234 return 0; | 234 return OrthancPluginErrorCode_Success; |
235 } | 235 } |
236 | 236 |
237 | 237 |
238 static int32_t ListServedFolders(OrthancPluginRestOutput* output, | 238 static OrthancPluginErrorCode ListServedFolders(OrthancPluginRestOutput* output, |
239 const char* url, | 239 const char* url, |
240 const OrthancPluginHttpRequest* request) | 240 const OrthancPluginHttpRequest* request) |
241 { | 241 { |
242 if (request->method != OrthancPluginHttpMethod_Get) | 242 if (request->method != OrthancPluginHttpMethod_Get) |
243 { | 243 { |
244 OrthancPluginSendMethodNotAllowed(context_, output, "GET"); | 244 OrthancPluginSendMethodNotAllowed(context_, output, "GET"); |
245 return 0; | 245 return OrthancPluginErrorCode_Success; |
246 } | 246 } |
247 | 247 |
248 std::string s = "<html><body><h1>Additional folders served by Orthanc</h1>\n"; | 248 std::string s = "<html><body><h1>Additional folders served by Orthanc</h1>\n"; |
249 | 249 |
250 if (folders_.empty()) | 250 if (folders_.empty()) |
266 | 266 |
267 s += "</body></html>\n"; | 267 s += "</body></html>\n"; |
268 | 268 |
269 OrthancPluginAnswerBuffer(context_, output, s.c_str(), s.size(), "text/html"); | 269 OrthancPluginAnswerBuffer(context_, output, s.c_str(), s.size(), "text/html"); |
270 | 270 |
271 return 0; | 271 return OrthancPluginErrorCode_Success; |
272 } | 272 } |
273 | 273 |
274 | 274 |
275 extern "C" | 275 extern "C" |
276 { | 276 { |