Exposing REST endpoints within Liberty

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

Pourquoi et quand exécuter cette tâche

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.

Procédure

  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. Packagez le composant dans un bundle OSGi qui fait partie de votre fonction utilisateur étendue.
  3. Assurez-vous que votre fonction inclut le contenu de sous-système OSGi :
    com.ibm.websphere.appserver.restHandler-1.0; type="osgi.subsystem.feature"
  4. Configurez les certificats SSL dans le fichier server.xml.
  5. Configurez un utilisateur ou un groupe avec le rôle d'administrateur dans le fichier server.xml.
    Remarque : Un utilisateur non administrateur peut accéder à votre noeud final REST si la propriété OSGi com.ibm.wsspi.rest.handler.RESTHandler.PROPERTY_REST_HANDLER_CUSTOM_SECURITY est définie sur true dans votre définition du gestionnaire REST.
  6. Démarrage votre fonction.

    Le démarrage de la fonction démarre la structure de gestionnaire REST et enregistre votre composant OSGi. Une fois la fonction démarrée, vous pouvez effectuer des appels vers https://<hôte>:<port_https>/ibm/api/myTest/abc.


Icône indiquant le type de rubrique Rubrique Tâche

Nom du fichier : twlp_expose_rest_endpoints.html