Mercurial > hg > orthanc
comparison Core/RestApi/RestApi.cpp @ 473:c9a5d72f8481
changing the namespace of HTTP enumerations
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Mon, 15 Jul 2013 17:22:13 +0200 |
parents | 1188cb0ddaa5 |
children | 6f8ae46ed90e |
comparison
equal
deleted
inserted
replaced
472:722b56b99093 | 473:c9a5d72f8481 |
---|---|
178 IsPostAccepted(uri) || | 178 IsPostAccepted(uri) || |
179 IsDeleteAccepted(uri)); | 179 IsDeleteAccepted(uri)); |
180 } | 180 } |
181 | 181 |
182 void RestApi::Handle(HttpOutput& output, | 182 void RestApi::Handle(HttpOutput& output, |
183 Orthanc_HttpMethod method, | 183 HttpMethod method, |
184 const UriComponents& uri, | 184 const UriComponents& uri, |
185 const Arguments& headers, | 185 const Arguments& headers, |
186 const Arguments& getArguments, | 186 const Arguments& getArguments, |
187 const std::string& postData) | 187 const std::string& postData) |
188 { | 188 { |
189 bool ok = false; | 189 bool ok = false; |
190 RestApiOutput restOutput(output); | 190 RestApiOutput restOutput(output); |
191 RestApiPath::Components components; | 191 RestApiPath::Components components; |
192 UriComponents trailing; | 192 UriComponents trailing; |
193 | 193 |
194 if (method == Orthanc_HttpMethod_Get) | 194 if (method == HttpMethod_Get) |
195 { | 195 { |
196 for (GetHandlers::const_iterator it = getHandlers_.begin(); | 196 for (GetHandlers::const_iterator it = getHandlers_.begin(); |
197 it != getHandlers_.end(); it++) | 197 it != getHandlers_.end(); it++) |
198 { | 198 { |
199 if (it->first->Match(components, trailing, uri)) | 199 if (it->first->Match(components, trailing, uri)) |
211 call.getArguments_ = &getArguments; | 211 call.getArguments_ = &getArguments; |
212 it->second(call); | 212 it->second(call); |
213 } | 213 } |
214 } | 214 } |
215 } | 215 } |
216 else if (method == Orthanc_HttpMethod_Put) | 216 else if (method == HttpMethod_Put) |
217 { | 217 { |
218 for (PutHandlers::const_iterator it = putHandlers_.begin(); | 218 for (PutHandlers::const_iterator it = putHandlers_.begin(); |
219 it != putHandlers_.end(); it++) | 219 it != putHandlers_.end(); it++) |
220 { | 220 { |
221 if (it->first->Match(components, trailing, uri)) | 221 if (it->first->Match(components, trailing, uri)) |
233 call.data_ = &postData; | 233 call.data_ = &postData; |
234 it->second(call); | 234 it->second(call); |
235 } | 235 } |
236 } | 236 } |
237 } | 237 } |
238 else if (method == Orthanc_HttpMethod_Post) | 238 else if (method == HttpMethod_Post) |
239 { | 239 { |
240 for (PostHandlers::const_iterator it = postHandlers_.begin(); | 240 for (PostHandlers::const_iterator it = postHandlers_.begin(); |
241 it != postHandlers_.end(); it++) | 241 it != postHandlers_.end(); it++) |
242 { | 242 { |
243 if (it->first->Match(components, trailing, uri)) | 243 if (it->first->Match(components, trailing, uri)) |
255 call.data_ = &postData; | 255 call.data_ = &postData; |
256 it->second(call); | 256 it->second(call); |
257 } | 257 } |
258 } | 258 } |
259 } | 259 } |
260 else if (method == Orthanc_HttpMethod_Delete) | 260 else if (method == HttpMethod_Delete) |
261 { | 261 { |
262 for (DeleteHandlers::const_iterator it = deleteHandlers_.begin(); | 262 for (DeleteHandlers::const_iterator it = deleteHandlers_.begin(); |
263 it != deleteHandlers_.end(); it++) | 263 it != deleteHandlers_.end(); it++) |
264 { | 264 { |
265 if (it->first->Match(components, trailing, uri)) | 265 if (it->first->Match(components, trailing, uri)) |
278 } | 278 } |
279 } | 279 } |
280 | 280 |
281 if (!ok) | 281 if (!ok) |
282 { | 282 { |
283 LOG(INFO) << "REST method " << Orthanc_HttpMethod_ToString(method) | 283 LOG(INFO) << "REST method " << Toolbox::ToString(method) |
284 << " not allowed on: " << Toolbox::FlattenUri(uri); | 284 << " not allowed on: " << Toolbox::FlattenUri(uri); |
285 output.SendMethodNotAllowedError(GetAcceptedMethods(uri)); | 285 output.SendMethodNotAllowedError(GetAcceptedMethods(uri)); |
286 } | 286 } |
287 } | 287 } |
288 | 288 |