comparison OrthancServer/main.cpp @ 1443:895ab369d63c

refactoring: OrthancHttpHandler
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 01 Jul 2015 11:30:19 +0200
parents 02f5a3f5c0a0
children b2b09a3dbd8e
comparison
equal deleted inserted replaced
1442:4ff8dd753d79 1443:895ab369d63c
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"
54 55
55 using namespace Orthanc; 56 using namespace Orthanc;
56 57
57 58
58 #define ENABLE_PLUGINS 1 59 #define ENABLE_PLUGINS 1
431 catch (...) 432 catch (...)
432 { 433 {
433 context->GetIndex().SetMaximumStorageSize(0); 434 context->GetIndex().SetMaximumStorageSize(0);
434 } 435 }
435 436
437
438 OrthancHttpHandler httpHandler;
439
440 #if ENABLE_PLUGINS == 1
441 OrthancRestApi restApi(*context);
442 plugins.SetServerContext(*context);
443 httpHandler.Register(plugins, false);
444 context->SetPlugins(plugins);
445 #endif
446
447 #if ORTHANC_STANDALONE == 1
448 EmbeddedResourceHttpHandler staticResources("/app", EmbeddedResources::ORTHANC_EXPLORER);
449 #else
450 FilesystemHttpHandler staticResources("/app", ORTHANC_PATH "/OrthancExplorer");
451 #endif
452
453 httpHandler.Register(staticResources, false);
454 httpHandler.Register(restApi, true);
455
456
457
436 MyDicomServerFactory serverFactory(*context); 458 MyDicomServerFactory serverFactory(*context);
437 bool isReset = false; 459 bool isReset = false;
438 460
439 { 461 {
440 // DICOM server 462 // DICOM server
469 else 491 else
470 { 492 {
471 httpServer.SetSslEnabled(false); 493 httpServer.SetSslEnabled(false);
472 } 494 }
473 495
474 OrthancRestApi restApi(*context); 496 httpServer.Register(httpHandler);
475
476 #if ORTHANC_STANDALONE == 1
477 EmbeddedResourceHttpHandler staticResources("/app", EmbeddedResources::ORTHANC_EXPLORER);
478 #else
479 FilesystemHttpHandler staticResources("/app", ORTHANC_PATH "/OrthancExplorer");
480 #endif
481
482 #if ENABLE_PLUGINS == 1
483 plugins.SetServerContext(*context);
484 httpServer.RegisterHandler(plugins);
485 context->SetPlugins(plugins);
486 #endif
487
488 httpServer.RegisterHandler(staticResources);
489 httpServer.RegisterHandler(restApi);
490 497
491 498
492 #if ENABLE_PLUGINS == 1 499 #if ENABLE_PLUGINS == 1
493 // Prepare the storage area 500 // Prepare the storage area
494 if (plugins.HasStorageArea()) 501 if (plugins.HasStorageArea())