Mercurial > hg > orthanc
annotate Core/RestApi/RestApi.cpp @ 984:e077093bf1a9 plugins
improvements
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 01 Jul 2014 14:30:42 +0200 |
parents | f1ff2a2f06cd |
children | 8d1845feb277 |
rev | line source |
---|---|
209 | 1 /** |
2 * Orthanc - A Lightweight, RESTful DICOM Store | |
689 | 3 * Copyright (C) 2012-2014 Medical Physics Department, CHU of Liege, |
209 | 4 * Belgium |
5 * | |
6 * This program is free software: you can redistribute it and/or | |
7 * modify it under the terms of the GNU General Public License as | |
8 * published by the Free Software Foundation, either version 3 of the | |
9 * License, or (at your option) any later version. | |
10 * | |
11 * In addition, as a special exception, the copyright holders of this | |
12 * program give permission to link the code of its release with the | |
13 * OpenSSL project's "OpenSSL" library (or with modified versions of it | |
14 * that use the same license as the "OpenSSL" library), and distribute | |
15 * the linked executables. You must obey the GNU General Public License | |
16 * in all respects for all of the code used other than "OpenSSL". If you | |
17 * modify file(s) with this exception, you may extend this exception to | |
18 * your version of the file(s), but you are not obligated to do so. If | |
19 * you do not wish to do so, delete this exception statement from your | |
20 * version. If you delete this exception statement from all source files | |
21 * in the program, then also delete it here. | |
22 * | |
23 * This program is distributed in the hope that it will be useful, but | |
24 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
26 * General Public License for more details. | |
27 * | |
28 * You should have received a copy of the GNU General Public License | |
29 * along with this program. If not, see <http://www.gnu.org/licenses/>. | |
30 **/ | |
31 | |
32 | |
824
a811bdf8b8eb
precompiled headers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
689
diff
changeset
|
33 #include "../PrecompiledHeaders.h" |
209 | 34 #include "RestApi.h" |
35 | |
249 | 36 #include <stdlib.h> // To define "_exit()" under Windows |
210
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
37 #include <glog/logging.h> |
96b7918a6a18
start of the refactoring of the Orthanc REST API
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
209
diff
changeset
|
38 |
980
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
39 #include <stdio.h> |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
40 |
209 | 41 namespace Orthanc |
42 { | |
980
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
43 namespace |
209 | 44 { |
980
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
45 // Anonymous namespace to avoid clashes between compilation modules |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
46 class HttpHandlerVisitor : public RestApiHierarchy::IVisitor |
209 | 47 { |
980
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
48 private: |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
49 RestApi& api_; |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
50 HttpOutput& output_; |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
51 HttpMethod method_; |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
52 const HttpHandler::Arguments& headers_; |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
53 const HttpHandler::Arguments& getArguments_; |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
54 const std::string& postData_; |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
55 |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
56 public: |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
57 HttpHandlerVisitor(RestApi& api, |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
58 HttpOutput& output, |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
59 HttpMethod method, |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
60 const HttpHandler::Arguments& headers, |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
61 const HttpHandler::Arguments& getArguments, |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
62 const std::string& postData) : |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
63 api_(api), |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
64 output_(output), |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
65 method_(method), |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
66 headers_(headers), |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
67 getArguments_(getArguments), |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
68 postData_(postData) |
209 | 69 { |
70 } | |
980
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
71 |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
72 virtual bool Visit(const RestApiHierarchy::Resource& resource, |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
73 const UriComponents& uri, |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
74 const HttpHandler::Arguments& components, |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
75 const UriComponents& trailing) |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
76 { |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
77 if (resource.HasHandler(method_)) |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
78 { |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
79 RestApiOutput output(output_); |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
80 |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
81 switch (method_) |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
82 { |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
83 case HttpMethod_Get: |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
84 { |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
85 RestApiGetCall call(output, api_, headers_, components, trailing, uri, getArguments_); |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
86 resource.Handle(call); |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
87 return true; |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
88 } |
209 | 89 |
980
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
90 case HttpMethod_Post: |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
91 { |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
92 RestApiPostCall call(output, api_, headers_, components, trailing, uri, postData_); |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
93 resource.Handle(call); |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
94 return true; |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
95 } |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
96 |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
97 case HttpMethod_Delete: |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
98 { |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
99 RestApiDeleteCall call(output, api_, headers_, components, trailing, uri); |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
100 resource.Handle(call); |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
101 return true; |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
102 } |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
103 |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
104 case HttpMethod_Put: |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
105 { |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
106 RestApiPutCall call(output, api_, headers_, components, trailing, uri, postData_); |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
107 resource.Handle(call); |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
108 return true; |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
109 } |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
110 |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
111 default: |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
112 return false; |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
113 } |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
114 } |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
115 |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
116 return false; |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
117 } |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
118 }; |
209 | 119 } |
120 | |
121 | |
122 | |
123 static void AddMethod(std::string& target, | |
124 const std::string& method) | |
125 { | |
126 if (target.size() > 0) | |
127 target += "," + method; | |
128 else | |
129 target = method; | |
130 } | |
131 | |
980
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
132 static std::string MethodsToString(const std::set<HttpMethod>& methods) |
209 | 133 { |
134 std::string s; | |
135 | |
980
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
136 if (methods.find(HttpMethod_Get) != methods.end()) |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
137 { |
209 | 138 AddMethod(s, "GET"); |
980
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
139 } |
209 | 140 |
980
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
141 if (methods.find(HttpMethod_Post) != methods.end()) |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
142 { |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
143 AddMethod(s, "POST"); |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
144 } |
209 | 145 |
980
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
146 if (methods.find(HttpMethod_Put) != methods.end()) |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
147 { |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
148 AddMethod(s, "PUT"); |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
149 } |
209 | 150 |
980
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
151 if (methods.find(HttpMethod_Delete) != methods.end()) |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
152 { |
209 | 153 AddMethod(s, "DELETE"); |
980
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
154 } |
209 | 155 |
156 return s; | |
157 } | |
158 | |
159 | |
160 | |
895
7e8cde5905fd
allow superposition of REST handlers
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
824
diff
changeset
|
161 bool RestApi::Handle(HttpOutput& output, |
473
c9a5d72f8481
changing the namespace of HTTP enumerations
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
416
diff
changeset
|
162 HttpMethod method, |
209 | 163 const UriComponents& uri, |
164 const Arguments& headers, | |
165 const Arguments& getArguments, | |
166 const std::string& postData) | |
167 { | |
980
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
168 HttpHandlerVisitor visitor(*this, output, method, headers, getArguments, postData); |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
169 |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
170 if (root_.LookupResource(uri, visitor)) |
901
7d88f3f4a3b3
refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
895
diff
changeset
|
171 { |
980
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
172 return true; |
901
7d88f3f4a3b3
refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
895
diff
changeset
|
173 } |
7d88f3f4a3b3
refactoring IsServedUri, answer PNG images, regular expression groups
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
895
diff
changeset
|
174 |
980
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
175 Json::Value directory; |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
176 if (root_.GetDirectory(directory, uri)) |
209 | 177 { |
980
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
178 RestApiOutput tmp(output); |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
179 tmp.AnswerJson(directory); |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
180 return true; |
209 | 181 } |
182 | |
980
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
183 std::set<HttpMethod> methods; |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
184 root_.GetAcceptedMethods(methods, uri); |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
185 |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
186 if (methods.empty()) |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
187 { |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
188 return false; // This URI is not served by this REST API |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
189 } |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
190 else |
209 | 191 { |
477 | 192 LOG(INFO) << "REST method " << EnumerationToString(method) |
416 | 193 << " not allowed on: " << Toolbox::FlattenUri(uri); |
980
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
194 |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
195 output.SendMethodNotAllowedError(MethodsToString(methods)); |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
196 |
f1ff2a2f06cd
use RestApiHierarchy inside RestApi
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
977
diff
changeset
|
197 return true; |
209 | 198 } |
199 } | |
200 | |
201 void RestApi::Register(const std::string& path, | |
974 | 202 RestApiGetCall::Handler handler) |
209 | 203 { |
977 | 204 root_.Register(path, handler); |
209 | 205 } |
206 | |
207 void RestApi::Register(const std::string& path, | |
974 | 208 RestApiPutCall::Handler handler) |
209 | 209 { |
977 | 210 root_.Register(path, handler); |
209 | 211 } |
212 | |
213 void RestApi::Register(const std::string& path, | |
974 | 214 RestApiPostCall::Handler handler) |
209 | 215 { |
977 | 216 root_.Register(path, handler); |
209 | 217 } |
218 | |
219 void RestApi::Register(const std::string& path, | |
974 | 220 RestApiDeleteCall::Handler handler) |
209 | 221 { |
977 | 222 root_.Register(path, handler); |
209 | 223 } |
224 } |