@@ -9,36 +9,44 @@ Parameter HandleCorsRequest = 1;
9
9
10
10
Parameter PAGESIZE As INTEGER = 20 ;
11
11
12
+ Parameter HTTP451LEGAL = " 451 Unavailable For Legal Reasons" ;
13
+
12
14
ClassMethod OnPreDispatch (pUrl As %String , pMethod As %String , ByRef pContinue As %Boolean ) As %Status
13
15
{
14
- SET tSC = $$$OK
15
- TRY {
16
-
16
+ Set tSC = $$$OK
17
+ Try {
17
18
// Set the return type according to the Accept type in the request. Default is application/json.
18
- IF ('..AcceptsContentType (..#CONTENTTYPEJSON)) {
19
- SET tSC = ..ReportHttpStatusCode (..#HTTP406NOTACCEPTABLE), pContinue =0
20
- QUIT
21
- } ELSE {
19
+ If ('..AcceptsContentType (..#CONTENTTYPEJSON)) {
20
+ Set tSC = ..ReportHttpStatusCode (..#HTTP406NOTACCEPTABLE)
21
+ Set pContinue = 0
22
+ Quit
23
+ } Else {
22
24
// This always returns json
23
- SET %response .ContentType =..#CONTENTTYPEJSON
24
- }
25
-
26
-
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 )
35
- }
25
+ Set %response .ContentType =..#CONTENTTYPEJSON
36
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
+ }
37
35
38
- } CATCH ex {
39
- SET tSC = ex .AsStatus ()
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 )
44
+ }
45
+ }
46
+ } Catch ex {
47
+ Set tSC = ex .AsStatus ()
40
48
}
41
- QUIT ##class (%iKnow.REST.Base ).%ErrorHandler (tSC , .pContinue )
49
+ Quit ##class (%iKnow.REST.Base ).%ErrorHandler (tSC , .pContinue )
42
50
}
43
51
44
52
ClassMethod %ProcessResult (pStatus As %Status = {$$$OK}, pResult As %DynamicObject = " " ) As %Status [ Internal ]
0 commit comments