Skip to Main Content
InterSystems Ideas

Have an idea, suggestion, or something that doesn’t work as expected in InterSystems products or services? Share it here on the InterSystems Ideas Portal.

The Ideas Portal is where community members can propose improvements, report bugs, and help influence the product roadmap across InterSystems products and the overall developer experience. 22% of submitted ideas are implemented by InterSystems or members of the Developer Community.

💡 Ideas and bugs are both welcome, no matter how big or small. You can submit feature requests, usability improvements, workflow suggestions, and bug reports. Whether you’re an experienced expert or just getting started, your fresh perspective is valuable.

🛠️ About bugs and fixes. If you have access to InterSystems WRC, please submit bugs there for immediate action. Bug reports submitted through the Ideas Portal are reviewed and tracked, but do not guarantee immediate resolution.

Start by sharing what could be better - the community and our teams will help take it from there.

Status Ideas Contest
Categories InterSystems IRIS
Created by Shun Kondo
Created on Feb 27, 2025

Allow overriding of the class method call for routing within %CSP.REST.DispatchRequest

I would like the process of calling the destination class method within the DispatchRequest method of the %CSP.REST class to be an overridable method.

Currently, I am manually creating REST APIs using ObjectScript. When there are cross-cutting concerns that I want to handle in all the class methods mapped by UrlMap (such as common exception handling with try-catch, logging, etc.), I have to write boilerplate code in all the class methods. (Although there is an OnPreDispatch method, this method cannot control exceptions that occur in the class methods mapped by UrlMap with common exception handling.)

As a specific proposal, could the following code in the DispatchRequest method within the %CSP.REST class, which calls the final destination class method, be changed as follows? (Or add an overridable callback method equivalent to the following.)

Before change:

Within the %CSP.REST DispatchRequest method:

#; Dispatch
Set tSC=$classmethod(tClass,tTarget,pArgs...)

After change:

Within the %CSP.REST class:

/// Define a new method in %CSP.REST
ClassMethod InvokeRestMethod(tClass As %String, tTarget As %String, pArgs... As %String) As %Status
{
return $classmethod(tClass,tTarget,pArgs...)
}

Within the DispatchRequest method:

#; Dispatch
Set tSC=..InvokeRestMethod(tClass,tTarget,pArgs...)
#; Old
#; Set tSC=$classmethod(tClass,tTarget,pArgs...)

Users can define a derived class as follows and inherit it in all REST classes where they want to perform common processing, allowing them to manage boilerplate code for cases such as exception handling in a single class method.

/// Override in a class that inherits from %CSP.REST
ClassMethod InvokeRestMethod(tClass As %String, tTarget As %String, pArgs... As %String) As %Status
{       
set status = $$$OK
try {
tstart
set status = ##super(tClass, tTarget, pArgs...)
if ($$$ISERR(status)) {
trollback
} else {
tcommit
}
} catch ex {
trollback
set status=ex.AsStatus()
}
return status
}

By adding such a method, users who manually create REST APIs can have a better development experience. Is it possible to implement this idea or a similar feature?

  • ADMIN RESPONSE
    May 9, 2025

    Thank you for submitting an idea for the Ideas contest. The status changed to "Ideas Contest".

    Please answer the experts' clarifying questions, if any, during the contest and voting period.