Mercurial > hg > orthanc
comparison OrthancFramework/Sources/RestApi/RestApi.cpp @ 4400:029366f95217
cppcheck
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 23 Dec 2020 12:30:56 +0100 |
parents | 80fd140b12ba |
children | 354ea95b294a |
comparison
equal
deleted
inserted
replaced
4399:80fd140b12ba | 4400:029366f95217 |
---|---|
77 const UriComponents& uri, | 77 const UriComponents& uri, |
78 bool hasTrailing, | 78 bool hasTrailing, |
79 const HttpToolbox::Arguments& components, | 79 const HttpToolbox::Arguments& components, |
80 const UriComponents& trailing) | 80 const UriComponents& trailing) |
81 { | 81 { |
82 if (resource.HasMethod(method_)) | 82 if (resource.HasHandler(method_)) |
83 { | 83 { |
84 switch (method_) | 84 switch (method_) |
85 { | 85 { |
86 case HttpMethod_Get: | 86 case HttpMethod_Get: |
87 { | 87 { |
131 private: | 131 private: |
132 RestApi& restApi_; | 132 RestApi& restApi_; |
133 Json::Value paths_; | 133 Json::Value paths_; |
134 | 134 |
135 public: | 135 public: |
136 OpenApiVisitor(RestApi& restApi) : | 136 explicit OpenApiVisitor(RestApi& restApi) : |
137 restApi_(restApi) | 137 restApi_(restApi) |
138 { | 138 { |
139 } | 139 } |
140 | 140 |
141 virtual bool Visit(const RestApiHierarchy::Resource& resource, | 141 virtual bool Visit(const RestApiHierarchy::Resource& resource, |
144 const HttpToolbox::Arguments& components, | 144 const HttpToolbox::Arguments& components, |
145 const UriComponents& trailing) | 145 const UriComponents& trailing) |
146 { | 146 { |
147 const std::string path = Toolbox::FlattenUri(uri); | 147 const std::string path = Toolbox::FlattenUri(uri); |
148 | 148 |
149 if (hasTrailing) | |
150 LOG(WARNING) << ">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " << path; | |
151 | |
152 if (paths_.isMember(path)) | 149 if (paths_.isMember(path)) |
153 { | 150 { |
154 throw OrthancException(ErrorCode_InternalError); | 151 throw OrthancException(ErrorCode_InternalError); |
155 } | 152 } |
156 | 153 |
157 //if (path == "/patients/{id}/protected") | 154 if (resource.HasHandler(HttpMethod_Get)) |
158 //asm("int $3"); | |
159 | |
160 if (resource.HasMethod(HttpMethod_Get)) | |
161 { | 155 { |
162 StringHttpOutput o1; | 156 StringHttpOutput o1; |
163 HttpOutput o2(o1, false); | 157 HttpOutput o2(o1, false); |
164 RestApiOutput o3(o2, HttpMethod_Get); | 158 RestApiOutput o3(o2, HttpMethod_Get); |
165 RestApiGetCall call(o3, restApi_, RequestOrigin_Documentation, "" /* remote IP */, | 159 RestApiGetCall call(o3, restApi_, RequestOrigin_Documentation, "" /* remote IP */, |
191 { | 185 { |
192 LOG(WARNING) << "Ignoring URI without API documentation: GET " << path; | 186 LOG(WARNING) << "Ignoring URI without API documentation: GET " << path; |
193 } | 187 } |
194 } | 188 } |
195 | 189 |
196 if (resource.HasMethod(HttpMethod_Post)) | 190 if (resource.HasHandler(HttpMethod_Post)) |
197 { | 191 { |
198 StringHttpOutput o1; | 192 StringHttpOutput o1; |
199 HttpOutput o2(o1, false); | 193 HttpOutput o2(o1, false); |
200 RestApiOutput o3(o2, HttpMethod_Post); | 194 RestApiOutput o3(o2, HttpMethod_Post); |
201 RestApiPostCall call(o3, restApi_, RequestOrigin_Documentation, "" /* remote IP */, | 195 RestApiPostCall call(o3, restApi_, RequestOrigin_Documentation, "" /* remote IP */, |
226 { | 220 { |
227 LOG(WARNING) << "Ignoring URI without API documentation: POST " << path; | 221 LOG(WARNING) << "Ignoring URI without API documentation: POST " << path; |
228 } | 222 } |
229 } | 223 } |
230 | 224 |
231 if (resource.HasMethod(HttpMethod_Delete)) | 225 if (resource.HasHandler(HttpMethod_Delete)) |
232 { | 226 { |
233 StringHttpOutput o1; | 227 StringHttpOutput o1; |
234 HttpOutput o2(o1, false); | 228 HttpOutput o2(o1, false); |
235 RestApiOutput o3(o2, HttpMethod_Delete); | 229 RestApiOutput o3(o2, HttpMethod_Delete); |
236 RestApiDeleteCall call(o3, restApi_, RequestOrigin_Documentation, "" /* remote IP */, | 230 RestApiDeleteCall call(o3, restApi_, RequestOrigin_Documentation, "" /* remote IP */, |
261 { | 255 { |
262 LOG(WARNING) << "Ignoring URI without API documentation: DELETE " << path; | 256 LOG(WARNING) << "Ignoring URI without API documentation: DELETE " << path; |
263 } | 257 } |
264 } | 258 } |
265 | 259 |
266 if (resource.HasMethod(HttpMethod_Put)) | 260 if (resource.HasHandler(HttpMethod_Put)) |
267 { | 261 { |
268 StringHttpOutput o1; | 262 StringHttpOutput o1; |
269 HttpOutput o2(o1, false); | 263 HttpOutput o2(o1, false); |
270 RestApiOutput o3(o2, HttpMethod_Put); | 264 RestApiOutput o3(o2, HttpMethod_Put); |
271 RestApiPutCall call(o3, restApi_, RequestOrigin_Documentation, "" /* remote IP */, | 265 RestApiPutCall call(o3, restApi_, RequestOrigin_Documentation, "" /* remote IP */, |