@@ -9,44 +9,36 @@ Parameter HandleCorsRequest = 1;
9
9
10
10
Parameter PAGESIZE As INTEGER = 20 ;
11
11
12
- Parameter HTTP451LEGAL = " 451 Unavailable For Legal Reasons" ;
13
-
14
12
ClassMethod OnPreDispatch (pUrl As %String , pMethod As %String , ByRef pContinue As %Boolean ) As %Status
15
13
{
16
- Set tSC = $$$OK
17
- Try {
14
+ SET tSC = $$$OK
15
+ TRY {
16
+
18
17
// Set the return type according to the Accept type in the request. Default is application/json.
19
- If ('..AcceptsContentType (..#CONTENTTYPEJSON)) {
20
- Set tSC = ..ReportHttpStatusCode (..#HTTP406NOTACCEPTABLE)
21
- Set pContinue = 0
22
- Quit
23
- } Else {
18
+ IF ('..AcceptsContentType (..#CONTENTTYPEJSON)) {
19
+ SET tSC = ..ReportHttpStatusCode (..#HTTP406NOTACCEPTABLE), pContinue =0
20
+ QUIT
21
+ } ELSE {
24
22
// This always returns json
25
- Set %response .ContentType =..#CONTENTTYPEJSON
26
- }
27
-
28
- If (##class (%Dictionary.CompiledClass ).%ExistsId (" ZPM.Analytics.IP" )) {
29
- If ('##class (ZPM.Analytics.IP ).ValidateIP (..GetRemoteAddr ())) {
30
- Set tSC = ..ReportHttpStatusCode (..#HTTP451LEGAL)
31
- Set pContinue = 0
32
- Quit
33
- }
34
- }
23
+ SET %response .ContentType =..#CONTENTTYPEJSON
24
+ }
25
+
35
26
36
- // read request object into %DynamicObject format
37
- If ((pMethod '=" POST" ) && (pMethod '=" PUT" )) || (%request .Content =" " ) {
38
- Set %request .Content = {}
39
- } Else {
40
- If ($IsObject (%request .Content ))&&('%request .Content .Size ) {
41
- Set %request .Content = {}
42
- } Else {
43
- Set %request .Content = ##class (%Library.DynamicObject ).%FromJSON (%request .Content )
27
+ // read request object into %DynamicObject format
28
+ IF ((pMethod '=" POST" ) && (pMethod '=" PUT" )) || (%request .Content =" " ) {
29
+ SET %request .Content = {}
30
+ } ELSE {
31
+ IF ($IsObject (%request .Content ))&&('%request .Content .Size ) {
32
+ SET %request .Content = {}
33
+ } ELSE {
34
+ SET %request .Content = ##class (%Library.DynamicObject ).%FromJSON (%request .Content )
44
35
}
45
- }
46
- } Catch ex {
47
- Set tSC = ex .AsStatus ()
36
+ }
37
+
38
+ } CATCH ex {
39
+ SET tSC = ex .AsStatus ()
48
40
}
49
- Quit ##class (%iKnow.REST.Base ).%ErrorHandler (tSC , .pContinue )
41
+ QUIT ##class (%iKnow.REST.Base ).%ErrorHandler (tSC , .pContinue )
50
42
}
51
43
52
44
ClassMethod %ProcessResult (pStatus As %Status = {$$$OK}, pResult As %DynamicObject = " " ) As %Status [ Internal ]
0 commit comments