Exposing REST endpoints within Liberty

You can use the REST Handler framework in the Liberty SPI to expose new REST endpoints.

About this task

The REST Handler framework is for Liberty extenders to use when exposing new REST endpoints. You can expose REST endpoints in an OSGi component, or a set of components.

Procedure

  1. 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 {
    ...
  2. Package the component into an OSGi bundle that is part of your extended user feature.
  3. Ensure that your feature includes the OSGi subsystem content:
    com.ibm.websphere.appserver.restHandler-1.0; type="osgi.subsystem.feature"
  4. Configure SSL certificates in the server.xml file.
  5. Configure a user or group to the administrator role in the server.xml file.
    Note: A non-administrator user can access your REST endpoint if the OSGi property com.ibm.wsspi.rest.handler.RESTHandler.PROPERTY_REST_HANDLER_CUSTOM_SECURITY is set to true in your REST handler definition.
  6. Start your feature.

    Starting the feature starts the REST Handler framework and registers your OSGi component. After the feature starts, you can make calls to https://<host>:<https_port>/ibm/api/myTest/abc.


Icon that indicates the type of topic Task topic



Timestamp icon Last updated: Monday, 5 December 2016
http://www14.software.ibm.com/webapp/wsbroker/redirect?version=cord&product=was-libcore-mp&topic=twlp_expose_rest_endpoints
File name: twlp_expose_rest_endpoints.html