Mercurial > hg > orthanc
comparison Plugins/Samples/Basic/Plugin.c @ 1962:22ddb22fce83
sample plugin
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 07 Apr 2016 17:42:20 +0200 |
parents | b1291df2f780 |
children | cadfe0a2a393 |
comparison
equal
deleted
inserted
replaced
1961:ef1e9856c26f | 1962:22ddb22fce83 |
---|---|
320 | 320 |
321 return OrthancPluginErrorCode_Success; | 321 return OrthancPluginErrorCode_Success; |
322 } | 322 } |
323 | 323 |
324 | 324 |
325 ORTHANC_PLUGINS_API int32_t FilterIncomingHttpRequest(OrthancPluginHttpMethod method, | |
326 const char* uri, | |
327 const char* ip, | |
328 uint32_t headersCount, | |
329 const char* const* headersKeys, | |
330 const char* const* headersValues) | |
331 { | |
332 uint32_t i; | |
333 | |
334 if (headersCount > 0) | |
335 { | |
336 OrthancPluginLogInfo(context, "HTTP headers of an incoming REST request:"); | |
337 for (i = 0; i < headersCount; i++) | |
338 { | |
339 char info[1024]; | |
340 sprintf(info, " %s: %s", headersKeys[i], headersValues[i]); | |
341 OrthancPluginLogInfo(context, info); | |
342 } | |
343 } | |
344 | |
345 if (method == OrthancPluginHttpMethod_Get || | |
346 method == OrthancPluginHttpMethod_Post) | |
347 { | |
348 return 1; /* Allowed */ | |
349 } | |
350 else | |
351 { | |
352 return 0; /* Only allow GET and POST requests */ | |
353 } | |
354 } | |
355 | |
356 | |
325 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* c) | 357 ORTHANC_PLUGINS_API int32_t OrthancPluginInitialize(OrthancPluginContext* c) |
326 { | 358 { |
327 OrthancPluginMemoryBuffer tmp; | 359 OrthancPluginMemoryBuffer tmp; |
328 char info[1024], *s; | 360 char info[1024], *s; |
329 int counter, i; | 361 int counter, i; |
382 OrthancPluginRegisterRestCallback(context, "/forward/(built-in)(/.+)", Callback5); | 414 OrthancPluginRegisterRestCallback(context, "/forward/(built-in)(/.+)", Callback5); |
383 OrthancPluginRegisterRestCallback(context, "/forward/(plugins)(/.+)", Callback5); | 415 OrthancPluginRegisterRestCallback(context, "/forward/(plugins)(/.+)", Callback5); |
384 OrthancPluginRegisterRestCallback(context, "/plugin/create", CallbackCreateDicom); | 416 OrthancPluginRegisterRestCallback(context, "/plugin/create", CallbackCreateDicom); |
385 | 417 |
386 OrthancPluginRegisterOnStoredInstanceCallback(context, OnStoredCallback); | 418 OrthancPluginRegisterOnStoredInstanceCallback(context, OnStoredCallback); |
387 | |
388 OrthancPluginRegisterOnChangeCallback(context, OnChangeCallback); | 419 OrthancPluginRegisterOnChangeCallback(context, OnChangeCallback); |
420 OrthancPluginRegisterIncomingHttpRequestFilter(context, FilterIncomingHttpRequest); | |
389 | 421 |
390 /* Declare several properties of the plugin */ | 422 /* Declare several properties of the plugin */ |
391 OrthancPluginSetRootUri(context, "/plugin/hello"); | 423 OrthancPluginSetRootUri(context, "/plugin/hello"); |
392 OrthancPluginSetDescription(context, "This is the description of the sample plugin that can be seen in Orthanc Explorer."); | 424 OrthancPluginSetDescription(context, "This is the description of the sample plugin that can be seen in Orthanc Explorer."); |
393 OrthancPluginExtendOrthancExplorer(context, "alert('Hello Orthanc! From sample plugin with love.');"); | 425 OrthancPluginExtendOrthancExplorer(context, "alert('Hello Orthanc! From sample plugin with love.');"); |