In https://github.com/opensearch-project/OpenSearch/pull/7957, the NamedRoute class is being implemented to replace existing extension Route and RouteHandler options. For the security implementation it will be required that Extensions implement this.
One of the builder's required arguments is a handler with type Function<RestRequest, RestResponse>. Extensions are expected to use the ExtensionRestResponse class whose entire reason for existence is to communicate a list of consumed parameters, and a consumed content boolean, to OpenSearch.
Enforcing the ExtensionRestResponse type is most easily done with a subclass, but NamedRoute does not permit inheritance.
What solution would you like?
We can create an ExtensionRequestHandler class which either enforces the ExtensionRestResponse type, or better yet, handles all the checking of consumed params within the SDK and includes some of the "exceptional Response" handling we currently get in the BaseExtensionRestHandler class.
We've already had to special-case consuming params and content on the OpenSearch side of transport for the case of exceptions; we could just make that the default if it's always handled on the SDK side.
Is your feature request related to a problem?
In https://github.com/opensearch-project/OpenSearch/pull/7957, the
NamedRoute
class is being implemented to replace existing extensionRoute
andRouteHandler
options. For the security implementation it will be required that Extensions implement this.One of the builder's required arguments is a handler with type
Function<RestRequest, RestResponse>
. Extensions are expected to use theExtensionRestResponse
class whose entire reason for existence is to communicate a list of consumed parameters, and a consumed content boolean, to OpenSearch.Enforcing the
ExtensionRestResponse
type is most easily done with a subclass, butNamedRoute
does not permit inheritance.What solution would you like?
We can create an
ExtensionRequestHandler
class which either enforces theExtensionRestResponse
type, or better yet, handles all the checking of consumed params within the SDK and includes some of the "exceptional Response" handling we currently get in theBaseExtensionRestHandler
class.We've already had to special-case consuming params and content on the OpenSearch side of transport for the case of exceptions; we could just make that the default if it's always handled on the SDK side.
What alternatives have you considered?
Lots more type checks in the existing code.
Do you have any additional context?
Some of this may be handled in #622