Exposing REST endpoints within the Liberty profile
We can use the REST Handler framework in the Liberty SPI to expose new REST endpoints.
The REST Handler framework is for Liberty extenders to use when exposing new REST endpoints. We can expose REST endpoints in an OSGi component, or a set of components.
- Create an OSGi component that registers itself as listening to a sub-root that appends to /ibm/api and implements the com.ibm.wsspi.rest.handler.RESTHandler interface; for example:
@Component(service = { RESTHandler.class }, configurationPolicy = ConfigurationPolicy.IGNORE, immediate = true, property = { "service.vendor=IBM", RESTHandler.PROPERTY_REST_HANDLER_ROOT + "=/myTest/abc" }) public class RESTHANDLERTest1 implements RESTHandler { ...
- Package the component into an OSGi bundle that is part of the extended user feature.
- Ensure that the feature includes the OSGi subsystem content:
com.ibm.websphere.appserver.restHandler-1.0; type="osgi.subsystem.feature"
- Configure SSL certificates in server.xml.
- Configure a user or group to the administrator role in server.xml.
- Start the feature.
Start the feature starts the REST Handler framework and registers the OSGi component. After the feature starts, we can make calls to https://<host>:<https_port>/ibm/api/myTest/abc.
Parent topic: Liberty SPI utilitiesRelated information:
Liberty SPI -- WebSphere REST Handler SPI