Mercurial > hg > orthanc
comparison Plugins/Engine/PluginsManager.cpp @ 896:c4053ac5db04 plugins
better plugni api
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 17 Jun 2014 09:57:02 +0200 |
parents | 690aeb4cb899 |
children | bafc9d592632 |
comparison
equal
deleted
inserted
replaced
895:7e8cde5905fd | 896:c4053ac5db04 |
---|---|
145 { | 145 { |
146 LOG(INFO) << str; | 146 LOG(INFO) << str; |
147 } | 147 } |
148 | 148 |
149 void PluginsManager::RegisterRestCallback(const OrthancPluginContext* context, | 149 void PluginsManager::RegisterRestCallback(const OrthancPluginContext* context, |
150 const char* path, | 150 const char* pathRegularExpression, |
151 OrthancRestCallback callback) | 151 OrthancPluginRestCallback callback) |
152 { | 152 { |
153 // TODO | 153 // TODO |
154 LOG(INFO) << "Plugin has registered a REST callback on: " << path; | 154 LOG(INFO) << "Plugin has registered a REST callback on: " << pathRegularExpression; |
155 | 155 |
156 PluginsManager* manager = reinterpret_cast<PluginsManager*>(context->pimpl); | 156 PluginsManager* manager = reinterpret_cast<PluginsManager*>(context->pimpl); |
157 manager->restCallbacks_.push_back(callback); | 157 manager->restCallbacks_.push_back(callback); |
158 | 158 |
159 | 159 callback(NULL, OrthancPluginHttpMethod_Get, "/hello/world", NULL, 0); |
160 const char* pp = "/hello/world"; | 160 } |
161 | 161 |
162 UriComponents components; | 162 |
163 Toolbox::SplitUriComponents(components, pp); | 163 static void AnswerBuffer(OrthancPluginRestOutput* output, |
164 | |
165 OrthancRestUrl url; | |
166 url.path = pp; | |
167 | |
168 std::vector<const char*> c(components.size()); | |
169 for (unsigned int i = 0; i < components.size(); i++) | |
170 { | |
171 c[i] = components[i].c_str(); | |
172 } | |
173 | |
174 if (components.size() == 0) | |
175 { | |
176 url.components = NULL; | |
177 url.componentsSize = 0; | |
178 } | |
179 else | |
180 { | |
181 url.components = &c[0]; | |
182 url.componentsSize = components.size(); | |
183 } | |
184 | |
185 // TODO | |
186 url.parameters = NULL; | |
187 url.parametersSize = 0; | |
188 | |
189 callback(NULL, OrthancHttpMethod_Get, &url, NULL, 0); | |
190 } | |
191 | |
192 | |
193 static void AnswerBuffer(OrthancRestOutput* output, | |
194 const char* answer, | 164 const char* answer, |
195 uint32_t answerSize, | 165 uint32_t answerSize, |
196 const char* mimeType) | 166 const char* mimeType) |
197 { | 167 { |
198 std::cout << "MIME " << mimeType << ": " << answer << std::endl; | 168 std::cout << "MIME " << mimeType << ": " << answer << std::endl; |
309 } | 279 } |
310 } | 280 } |
311 } | 281 } |
312 } | 282 } |
313 } | 283 } |
314 | |
315 } | 284 } |