I heed to his a callback method after all REST call. I have already found a method to call before REST call, but after eludes me. Here's the code:
Class Test.REST Extends %CSP.REST
{
XData UrlMap [ XMLNamespace = "http://www.intersystems.com/urlmap" ]
{
<Routes>
<Route Url="/:classname" Method="GET" Call="TEST" Cors="true"/>
</Routes>
}
/// This method Gets called prior to dispatch of the request. Put any common code here
/// that you want to be executed for EVERY request. If pContinue is set to 0, the
/// request will NOT be dispatched according to the UrlMap. If this case it's the
/// responsibility of the user to return a response.
ClassMethod OnPreDispatch(pUrl As %String, pMethod As %String, ByRef pContinue As %Boolean) As %Status
{
set ^CacheTemp.DBG($i(^CacheTemp.DBG)) = "OnPreDispatch"
set pContinue = $$$YES
quit $$$OK
}
ClassMethod TEST(name) As %Status
{
set ^CacheTemp.DBG($i(^CacheTemp.DBG)) = "TEST"
//w 1/0
quit $$$OK
}
/// Issue an '500' error and give some indication as to what occurred
ClassMethod Http500(pE As %Exception.AbstractException) As %Status
{
set ^CacheTemp.DBG($i(^CacheTemp.DBG)) = "Http500"
quit ##super()
}
/// Doesn't work
ClassMethod OnPostHTTP() [ Abstract, ServerOnly = 1 ]
{
set ^CacheTemp.DBG($i(^CacheTemp.DBG)) = "OnPostHTTP"
}
/// Doesn't work
ClassMethod OnPostHyperEvent(class As %String, method As %String) As %Status [ ServerOnly = 1 ]
{
set ^CacheTemp.DBG($i(^CacheTemp.DBG)) = "OnPostHyperEvent"
quit $$$OK
}
}

