|
60 | 60 | * Alle Post Methoden |
61 | 61 | *) |
62 | 62 | Function Setdir(Sender: TObject; Const aPath: String; Const aContent: TJSONObj): TPostResult; |
| 63 | + Function Shutdown(Sender: TObject; Const aPath: String; Const aContent: TJSONObj): TPostResult; |
63 | 64 | Function Job(Sender: TObject; Const aPath: String; Const aContent: TJSONObj): TPostResult; |
64 | 65 | public |
65 | 66 | Constructor Create; virtual; |
|
118 | 119 | fServer.RegisterGetHandler('/api/status', @GetStatus); |
119 | 120 | fServer.RegisterGetHandler('/api/view/list', @GetViewList); |
120 | 121 | fServer.RegisterPostHandler('/api/job', @Job); |
| 122 | + fServer.RegisterPostHandler('/api/shutdown', @Shutdown); |
121 | 123 |
|
122 | 124 | If ZombieMode Then Begin |
123 | 125 | fServer.RegisterPostHandler('/api/zombie/setdir', @Setdir); |
|
245 | 247 | End; |
246 | 248 | End; |
247 | 249 |
|
| 250 | +Function TRestAPIDummy.Shutdown(Sender: TObject; Const aPath: String; |
| 251 | + Const aContent: TJSONObj): TPostResult; |
| 252 | +Var |
| 253 | + jv: TJSONValue; |
| 254 | + SkipJobs: Boolean; |
| 255 | +Begin |
| 256 | + SkipJobs := false; |
| 257 | + result.HTTPCode := 400; |
| 258 | + result.Content := Nil; |
| 259 | + If assigned(aContent) Then Begin |
| 260 | + Try |
| 261 | + jv := aContent.FindPath('skipJobs') As TJSONValue; |
| 262 | + If assigned(jv) Then Begin |
| 263 | + SkipJobs := lowercase(trim(jv.Value)) = 'true'; |
| 264 | + End; |
| 265 | + Except |
| 266 | + exit; |
| 267 | + End; |
| 268 | + End; |
| 269 | + If (Not SkipJobs) And form1.fWorkThread.Busy Then Begin |
| 270 | + result.HTTPCode := 403; |
| 271 | + result.Content := TextNode('status', 'pending jobs, no permission to skip jobs.'); |
| 272 | + exit; |
| 273 | + End |
| 274 | + Else Begin |
| 275 | + result.HTTPCode := 200; |
| 276 | + result.Content := TextNode('status', 'ok'); |
| 277 | + End; |
| 278 | + // Set Flag "Shutdown" |
| 279 | + Form1.fShutdownbyRestRequest := true; |
| 280 | +End; |
| 281 | + |
248 | 282 | Function TRestAPIDummy.Job(Sender: TObject; Const aPath: String; |
249 | 283 | Const aContent: TJSONObj): TPostResult; |
250 | 284 |
|
|
0 commit comments