@@ -17,14 +17,17 @@ Add param Namespace to a request to execute MDX in desired namespace.]]></Descri
1717 #dim %response As %CSP.Response
1818 #dim %request As %CSP.Request
1919 #dim %session As %CSP.Session
20-
21- set %response.ContentType="text/json"
22- set %session.Language=$$MatchLanguage^%occMessages(%request.GetCgiEnv("HTTP_ACCEPT_LANGUAGE"),"%CSP","+s") // Localization support
23- set %response.Language=%session.Language
2420
25- //do %response.SetHeader("Access-Control-Allow-Origin","*")
26- //do %response.SetHeader("Access-Control-Allow-Headers","Authorization")
27- //return:($ZCVT(pMethod,"U") = "OPTIONS") $$$OK
21+ Do %response.SetHeader("Access-Control-Allow-Origin","*")
22+ Do %response.SetHeader("Access-Control-Allow-Methods","GET, PUT, POST, DELETE, OPTIONS")
23+ Do %response.SetHeader("Access-Control-Max-Age","10000")
24+ Do %response.SetHeader("Access-Control-Allow-Headers","Content-Type, Authorization, Accept-Language")
25+
26+ Set %response.CharSet = "utf-8"
27+ Set %response.ContentType="application/json"
28+
29+ Set %session.Language=$$MatchLanguage^%occMessages(%request.GetCgiEnv("HTTP_ACCEPT_LANGUAGE"),"%CSP","+s") // Localization support
30+ Set %response.Language=%session.Language
2831
2932 #dim tSC As %Status = $$$OK
3033 #dim e As %Exception.AbstractException
@@ -38,8 +41,8 @@ Add param Namespace to a request to execute MDX in desired namespace.]]></Descri
3841
3942 Try {
4043 // Desired execusion namespace
41- set Namespace = $get(%request.Data("Namespace",1))
42- set st = ..CheckNamespace(.Namespace)
44+ Set Namespace = $get(%request.Data("Namespace",1))
45+ Set st = ..CheckNamespace(.Namespace)
4346 If $$$ISERR(st) Do ..Http500(st) Quit
4447
4548 #; Check that the effective user ( could be unknown user ) can access this resource
@@ -105,18 +108,18 @@ Add param Namespace to a request to execute MDX in desired namespace.]]></Descri
105108 If tTarget[":" Set tClass=$Piece(tTarget,":"),tTarget=$Piece(tTarget,":",2)
106109
107110 #; Validate input
108- set tBody = $List(tMapEntry,4)
109- set tSC = ..ValidateRequest(pMethod,tBody)
111+ Set tBody = $List(tMapEntry,4)
112+ Set tSC = ..ValidateRequest(pMethod,tBody)
110113 If $$$ISERR(tSC) Do ..Http500(tSC) Quit
111114
112115 #; Dispatch
113- if (Namespace'=$Namespace) {
114- set oldNS = $Namespace
116+ If (Namespace'=$Namespace) {
117+ Set oldNS = $Namespace
115118 zn Namespace
116- set tSC=$zobjclassmethod(tClass,tTarget,tArgs...)
119+ Set tSC=$zobjclassmethod(tClass,tTarget,tArgs...)
117120 zn oldNS
118- } else {
119- set tSC=$zobjclassmethod(tClass,tTarget,tArgs...)
121+ } Else {
122+ Set tSC=$zobjclassmethod(tClass,tTarget,tArgs...)
120123 }
121124 If $$$ISERR(tSC) Do ..Http500(tSC)
122125
@@ -154,6 +157,30 @@ Converts request into UTF8. Converts request into proxyObject. ]]></Description>
154157]]> </Implementation >
155158</Method >
156159
160+ <Method name =" Login" >
161+ <Description >
162+ Called for a REST page in the event of a login being required</Description >
163+ <ClassMethod >1</ClassMethod >
164+ <FormalSpec >skipheader:%Boolean=1</FormalSpec >
165+ <ReturnType >%Status</ReturnType >
166+ <Implementation ><![CDATA[
167+ Do %response.SetHeader("Access-Control-Allow-Origin","*")
168+ Do %response.SetHeader("Access-Control-Allow-Methods","GET, PUT, POST, DELETE, OPTIONS")
169+ Do %response.SetHeader("Access-Control-Max-Age","10000")
170+ Do %response.SetHeader("Access-Control-Allow-Headers","Content-Type, Authorization, Accept-Language")
171+
172+ Set %response.CharSet = "utf-8"
173+ Set %response.ContentType="application/json"
174+
175+ If (%request.GetCgiEnv("REQUEST_METHOD") = "OPTIONS"){
176+ Do %response.WriteHTTPHeader()
177+ Return $$$OK
178+ }
179+
180+ Quit ##super(skipheader)
181+ ]]> </Implementation >
182+ </Method >
183+
157184<Method name =" Http500" >
158185<Description ><![CDATA[
159186Issue an '500' error and give some indication as to what occurred.<br>
@@ -166,7 +193,7 @@ Issue an '500' error and give some indication as to what occurred.<br>
166193 Set %response.Status="500 Internal Server Error"
167194
168195 #; Return a helpful error string
169- Write "{Error:"_$$$ZENJSSTR($System.Status.GetErrorText(pStatus,%session.Language))_"}"
196+ Write "{"" Error"" :"_$$$ZENJSSTR($System.Status.GetErrorText(pStatus,%session.Language))_"}"
170197]]> </Implementation >
171198</Method >
172199
@@ -278,7 +305,7 @@ This project creates the DispatchMethod used to dispatch the Url and Method to t
278305 }
279306 $$$GENERATE(" Quit """"")
280307
281- } else {
308+ } Else {
282309
283310 #; The specified class must have an XDATA Block named UrlMap
284311 Set tSC=$$$ERROR($$$XDataBlockMissing,tClassName,"UrlMap")
0 commit comments