comparison Core/RestApi/RestApi.cpp @ 1063:0332e6e8c679

Fix automated generation of the list of resource children in the REST API
author Sebastien Jodogne <s.jodogne@gmail.com>
date Fri, 25 Jul 2014 16:06:26 +0200
parents 00f9f36bcd94
children ba5c0908600c
comparison
equal deleted inserted replaced
1062:804a75413ee7 1063:0332e6e8c679
193 if (root_.LookupResource(uri, visitor)) 193 if (root_.LookupResource(uri, visitor))
194 { 194 {
195 return true; 195 return true;
196 } 196 }
197 197
198 Json::Value directory;
199 if (root_.GetDirectory(directory, uri))
200 {
201 wrappedOutput.AnswerJson(directory);
202 return true;
203 }
204
205 std::set<HttpMethod> methods; 198 std::set<HttpMethod> methods;
206 root_.GetAcceptedMethods(methods, uri); 199 root_.GetAcceptedMethods(methods, uri);
207 200
208 if (methods.empty()) 201 if (methods.empty())
209 { 202 {
241 void RestApi::Register(const std::string& path, 234 void RestApi::Register(const std::string& path,
242 RestApiDeleteCall::Handler handler) 235 RestApiDeleteCall::Handler handler)
243 { 236 {
244 root_.Register(path, handler); 237 root_.Register(path, handler);
245 } 238 }
239
240 void RestApi::AutoListChildren(RestApiGetCall& call)
241 {
242 RestApi& context = call.GetContext();
243
244 Json::Value directory;
245 if (context.root_.GetDirectory(directory, call.GetFullUri()))
246 {
247 call.GetOutput().AnswerJson(directory);
248 }
249 }
246 } 250 }