Mercurial > hg > orthanc
comparison OrthancServer/main.cpp @ 1444:b2b09a3dbd8e
refactoring: OrthancHttpHandler inside OrthancServer
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Wed, 01 Jul 2015 12:09:58 +0200 |
parents | 895ab369d63c |
children | 5ba7471780ae |
comparison
equal
deleted
inserted
replaced
1443:895ab369d63c | 1444:b2b09a3dbd8e |
---|---|
49 #include "OrthancFindRequestHandler.h" | 49 #include "OrthancFindRequestHandler.h" |
50 #include "OrthancMoveRequestHandler.h" | 50 #include "OrthancMoveRequestHandler.h" |
51 #include "ServerToolbox.h" | 51 #include "ServerToolbox.h" |
52 #include "../Plugins/Engine/OrthancPlugins.h" | 52 #include "../Plugins/Engine/OrthancPlugins.h" |
53 #include "FromDcmtkBridge.h" | 53 #include "FromDcmtkBridge.h" |
54 #include "OrthancHttpHandler.h" | |
55 | 54 |
56 using namespace Orthanc; | 55 using namespace Orthanc; |
57 | 56 |
58 | 57 |
59 #define ENABLE_PLUGINS 1 | 58 #define ENABLE_PLUGINS 1 |
433 { | 432 { |
434 context->GetIndex().SetMaximumStorageSize(0); | 433 context->GetIndex().SetMaximumStorageSize(0); |
435 } | 434 } |
436 | 435 |
437 | 436 |
438 OrthancHttpHandler httpHandler; | |
439 | |
440 #if ENABLE_PLUGINS == 1 | 437 #if ENABLE_PLUGINS == 1 |
441 OrthancRestApi restApi(*context); | 438 OrthancRestApi restApi(*context); |
442 plugins.SetServerContext(*context); | 439 plugins.SetServerContext(*context); |
443 httpHandler.Register(plugins, false); | 440 context->GetHttpHandler().Register(plugins, false); |
444 context->SetPlugins(plugins); | 441 context->SetPlugins(plugins); |
445 #endif | 442 #endif |
446 | 443 |
447 #if ORTHANC_STANDALONE == 1 | 444 #if ORTHANC_STANDALONE == 1 |
448 EmbeddedResourceHttpHandler staticResources("/app", EmbeddedResources::ORTHANC_EXPLORER); | 445 EmbeddedResourceHttpHandler staticResources("/app", EmbeddedResources::ORTHANC_EXPLORER); |
449 #else | 446 #else |
450 FilesystemHttpHandler staticResources("/app", ORTHANC_PATH "/OrthancExplorer"); | 447 FilesystemHttpHandler staticResources("/app", ORTHANC_PATH "/OrthancExplorer"); |
451 #endif | 448 #endif |
452 | 449 |
453 httpHandler.Register(staticResources, false); | 450 context->GetHttpHandler().Register(staticResources, false); |
454 httpHandler.Register(restApi, true); | 451 context->GetHttpHandler().Register(restApi, true); |
455 | |
456 | 452 |
457 | 453 |
458 MyDicomServerFactory serverFactory(*context); | 454 MyDicomServerFactory serverFactory(*context); |
459 bool isReset = false; | 455 bool isReset = false; |
460 | 456 |
491 else | 487 else |
492 { | 488 { |
493 httpServer.SetSslEnabled(false); | 489 httpServer.SetSslEnabled(false); |
494 } | 490 } |
495 | 491 |
496 httpServer.Register(httpHandler); | 492 httpServer.Register(context->GetHttpHandler()); |
497 | 493 |
498 | 494 |
499 #if ENABLE_PLUGINS == 1 | 495 #if ENABLE_PLUGINS == 1 |
500 // Prepare the storage area | 496 // Prepare the storage area |
501 if (plugins.HasStorageArea()) | 497 if (plugins.HasStorageArea()) |
508 { | 504 { |
509 storage.reset(Configuration::CreateStorageArea()); | 505 storage.reset(Configuration::CreateStorageArea()); |
510 } | 506 } |
511 | 507 |
512 context->SetStorageArea(*storage); | 508 context->SetStorageArea(*storage); |
513 context->GetLua().SetOrthancRestApi(restApi); | |
514 | 509 |
515 // GO !!! Start the requested servers | 510 // GO !!! Start the requested servers |
516 if (Configuration::GetGlobalBoolParameter("HttpServerEnabled", true)) | 511 if (Configuration::GetGlobalBoolParameter("HttpServerEnabled", true)) |
517 { | 512 { |
518 #if ENABLE_PLUGINS == 1 | 513 #if ENABLE_PLUGINS == 1 |
553 #if ENABLE_PLUGINS == 1 | 548 #if ENABLE_PLUGINS == 1 |
554 context->ResetPlugins(); | 549 context->ResetPlugins(); |
555 plugins.ResetOrthancRestApi(); | 550 plugins.ResetOrthancRestApi(); |
556 LOG(WARNING) << " Plugins have stopped"; | 551 LOG(WARNING) << " Plugins have stopped"; |
557 #endif | 552 #endif |
558 | |
559 context->GetLua().ResetOrthancRestApi(); | |
560 | 553 |
561 dicomServer.Stop(); | 554 dicomServer.Stop(); |
562 LOG(WARNING) << " DICOM server has stopped"; | 555 LOG(WARNING) << " DICOM server has stopped"; |
563 | 556 |
564 httpServer.Stop(); | 557 httpServer.Stop(); |