comparison OrthancServer/OrthancRestApi/OrthancRestApi.cpp @ 1730:bc34c69b594a

New URI "/tools/shutdown" to stop Orthanc from the REST API
author Sebastien Jodogne <s.jodogne@gmail.com>
date Wed, 21 Oct 2015 10:34:29 +0200
parents 904096e7367e
children b1291df2f780
comparison
equal deleted inserted replaced
1726:9d8bb6bc2890 1730:bc34c69b594a
57 } 57 }
58 58
59 59
60 void OrthancRestApi::ResetOrthanc(RestApiPostCall& call) 60 void OrthancRestApi::ResetOrthanc(RestApiPostCall& call)
61 { 61 {
62 OrthancRestApi::GetApi(call).leaveBarrier_ = true;
62 OrthancRestApi::GetApi(call).resetRequestReceived_ = true; 63 OrthancRestApi::GetApi(call).resetRequestReceived_ = true;
63 call.GetOutput().AnswerBuffer("{}", "application/json"); 64 call.GetOutput().AnswerBuffer("{}", "application/json");
65 }
66
67
68 void OrthancRestApi::ShutdownOrthanc(RestApiPostCall& call)
69 {
70 OrthancRestApi::GetApi(call).leaveBarrier_ = true;
71 call.GetOutput().AnswerBuffer("{}", "application/json");
72 LOG(WARNING) << "Shutdown request received";
64 } 73 }
65 74
66 75
67 76
68 77
97 106
98 // Registration of the various REST handlers -------------------------------- 107 // Registration of the various REST handlers --------------------------------
99 108
100 OrthancRestApi::OrthancRestApi(ServerContext& context) : 109 OrthancRestApi::OrthancRestApi(ServerContext& context) :
101 context_(context), 110 context_(context),
111 leaveBarrier_(false),
102 resetRequestReceived_(false) 112 resetRequestReceived_(false)
103 { 113 {
104 RegisterSystem(); 114 RegisterSystem();
105 115
106 RegisterChanges(); 116 RegisterChanges();
112 Register("/instances", UploadDicomFile); 122 Register("/instances", UploadDicomFile);
113 123
114 // Auto-generated directories 124 // Auto-generated directories
115 Register("/tools", RestApi::AutoListChildren); 125 Register("/tools", RestApi::AutoListChildren);
116 Register("/tools/reset", ResetOrthanc); 126 Register("/tools/reset", ResetOrthanc);
127 Register("/tools/shutdown", ShutdownOrthanc);
117 Register("/instances/{id}/frames/{frame}", RestApi::AutoListChildren); 128 Register("/instances/{id}/frames/{frame}", RestApi::AutoListChildren);
118 } 129 }
119 130
120 131
121 ServerContext& OrthancRestApi::GetContext(RestApiCall& call) 132 ServerContext& OrthancRestApi::GetContext(RestApiCall& call)