comparison Core/RestApi/RestApi.cpp @ 355:753e69f9326e

refactoring
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 30 Jan 2013 17:56:44 +0100
parents daff912c9ffe
children bdd72233b105
comparison
equal deleted inserted replaced
354:4d76fce206ef 355:753e69f9326e
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 const std::string& method, 183 Orthanc_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 == "GET") 194 if (method == Orthanc_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 == "PUT") 216 else if (method == Orthanc_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 == "POST") 238 else if (method == Orthanc_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 == "DELETE") 260 else if (method == Orthanc_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))