# HG changeset patch # User Andrew Wallis > # Date 1607716651 18000 # Node ID 9e2fc6911ac88c25c3988930e2c7006bde93c2ee # Parent b002f9abe802b3e93d789ddcc08cbbd331d019b1 adding option to disable orthance explorer when http server is enabled diff -r b002f9abe802 -r 9e2fc6911ac8 OrthancServer/Resources/Configuration.json --- a/OrthancServer/Resources/Configuration.json Thu Dec 17 11:27:37 2020 +0100 +++ b/OrthancServer/Resources/Configuration.json Fri Dec 11 14:57:31 2020 -0500 @@ -71,6 +71,12 @@ // Explorer will not be available. "HttpServerEnabled" : true, + // Enable/Disable the Orthanc Explorer UI. This option is only + // meaningful if the HttpServerEnabled is set to true + /** + "OrthancExplorerEnabled" : true, + **/ + // HTTP port for the REST services and for the GUI "HttpPort" : 8042, diff -r b002f9abe802 -r 9e2fc6911ac8 OrthancServer/Sources/OrthancRestApi/OrthancRestApi.cpp --- a/OrthancServer/Sources/OrthancRestApi/OrthancRestApi.cpp Thu Dec 17 11:27:37 2020 +0100 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestApi.cpp Fri Dec 11 14:57:31 2020 -0500 @@ -205,7 +205,8 @@ // Registration of the various REST handlers -------------------------------- - OrthancRestApi::OrthancRestApi(ServerContext& context) : + OrthancRestApi::OrthancRestApi(ServerContext& context, + bool orthancExplorerEnabled) : context_(context), leaveBarrier_(false), resetRequestReceived_(false), @@ -213,7 +214,7 @@ "orthanc_rest_api_active_requests", MetricsType_MaxOver10Seconds) { - RegisterSystem(); + RegisterSystem(orthancExplorerEnabled); RegisterChanges(); RegisterResources(); diff -r b002f9abe802 -r 9e2fc6911ac8 OrthancServer/Sources/OrthancRestApi/OrthancRestApi.h --- a/OrthancServer/Sources/OrthancRestApi/OrthancRestApi.h Thu Dec 17 11:27:37 2020 +0100 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestApi.h Fri Dec 11 14:57:31 2020 -0500 @@ -58,7 +58,7 @@ bool resetRequestReceived_; MetricsRegistry::SharedMetrics activeRequests_; - void RegisterSystem(); + void RegisterSystem(bool orthancExplorerEnabled); void RegisterChanges(); @@ -75,7 +75,8 @@ static void ShutdownOrthanc(RestApiPostCall& call); public: - explicit OrthancRestApi(ServerContext& context); + explicit OrthancRestApi(ServerContext& context, + bool orthancExplorerEnabled); virtual bool Handle(HttpOutput& output, RequestOrigin origin, diff -r b002f9abe802 -r 9e2fc6911ac8 OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp --- a/OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp Thu Dec 17 11:27:37 2020 +0100 +++ b/OrthancServer/Sources/OrthancRestApi/OrthancRestSystem.cpp Fri Dec 11 14:57:31 2020 -0500 @@ -556,9 +556,12 @@ } - void OrthancRestApi::RegisterSystem() + void OrthancRestApi::RegisterSystem(bool orthancExplorerEnabled) { - Register("/", ServeRoot); + if (orthancExplorerEnabled) + { + Register("/", ServeRoot); + } Register("/system", GetSystemInformation); Register("/statistics", GetStatistics); Register("/tools/generate-uid", GenerateUid); diff -r b002f9abe802 -r 9e2fc6911ac8 OrthancServer/Sources/main.cpp --- a/OrthancServer/Sources/main.cpp Thu Dec 17 11:27:37 2020 +0100 +++ b/OrthancServer/Sources/main.cpp Fri Dec 11 14:57:31 2020 -0500 @@ -1229,10 +1229,25 @@ FilesystemHttpHandler staticResources("/app", ORTHANC_PATH "/OrthancExplorer"); #endif - context.GetHttpHandler().Register(staticResources, false); + // Do not register static resources if orthanc explorer is disabled + bool orthancExplorerEnabled = false; + { + OrthancConfiguration::ReaderLock lock; + orthancExplorerEnabled = lock.GetConfiguration().GetBooleanParameter( + "OrthancExplorerEnabled", true); + } + + if (orthancExplorerEnabled) + { + context.GetHttpHandler().Register(staticResources, false); + } + else + { + LOG(WARNING) << "Orthanc Explorer UI is disabled"; + } // Thirdly, consider the built-in REST API of Orthanc - OrthancRestApi restApi(context); + OrthancRestApi restApi(context, orthancExplorerEnabled); context.GetHttpHandler().Register(restApi, true); context.SetupJobsEngine(false /* not running unit tests */, loadJobsFromDatabase);