Handler class methods
In order for the REST API framework to invoke a particular class method in a customer
handler class, the method must conform to a specific structure:
- The method must be public.
- The method must be non-static.
- The method name must match the value of the
operationIdproperty for the Swagger operation. - The method parameters must be of type
RequestContext, or, must have a name and type that matches a parameter declared on the operation configuration. - The method return type must be either
void, gw.api.rest.Response, or some type that the framework can serialize out. - The class containing the method must contain a no-argument constructor
If the
operationId is not a valid identifier for purposes of determining
the expected method name, the REST framework does the following:- It prepends a leading '_' character to the method name if the first character is not a valid identifier start.
- It replaces all other illegal characters with '_'.
Specifying handler classes
You specify the set of possible handler class for an API by either of the following
ways:
- Specify the set of handler classes directly on the operation using the
x-gw-apihandlerproperty. - Specify the list of handler classes on the
x-gw-apihandlerproperty of the root object and not at the operation level. The operation then uses the set of handler classes inherited from the root object if you do not specify the handler classes at the operation level.
However, the REST framework does not propagate the x-gw-apihandler value
on the root object across files during file combination. The defaults on the root object
apply only to operations defined in the original file. Any value set for the
x-gw-apihandler property at the operation level overrides the value of
this property set on the root object.
