Class HelidonRestServiceSupport

java.lang.Object
io.helidon.servicecommon.rest.HelidonRestServiceSupport
All Implemented Interfaces:
RestServiceSupport, Service
Direct Known Subclasses:
HealthSupport, MetricsSupport, MicrometerSupport, MinimalMetricsSupport

public abstract class HelidonRestServiceSupport extends Object implements RestServiceSupport
Common base implementation for service support classes which involve REST endpoints.

This base class takes care of some tasks common to many services, using config and other settings in the builder:

  • Setting up the endpoint path (web context) for the service, using settings in the builder and config.
  • Providing automatic CORS support (and the ability to control it via config).

Concrete implementations must implement postConfigureEndpoint(Routing.Rules, Routing.Rules) to do any service-specific routing. See also the HelidonRestServiceSupport.Builder information for possible additional overrides.

  • Constructor Details

    • HelidonRestServiceSupport

      protected HelidonRestServiceSupport(Logger logger, HelidonRestServiceSupport.Builder<?,?> builder, String serviceName)
      Shared initialization for new service support instances.
      Parameters:
      logger - the Logger for the concrete service support instance
      builder - builder for the service support instance.
      serviceName - name of the service
    • HelidonRestServiceSupport

      protected HelidonRestServiceSupport(Logger logger, RestServiceSettings restServiceSettings, String serviceName)
      Creates a new service support instance with the specified logger, REST settings, and service name.
      Parameters:
      logger - subclass-specific logger to use
      restServiceSettings - REST service settings to use
      serviceName - service name for the REST service
  • Method Details

    • configureEndpoint

      public final void configureEndpoint(Routing.Rules defaultRules, Routing.Rules serviceEndpointRoutingRules)
      Configures service endpoint on the provided routing rules. This method just adds the endpoint path (as defaulted or configured). This method is exclusive to Service.update(io.helidon.webserver.Routing.Rules) (e.g. you should not use both, as otherwise you would register the endpoint twice)
      Specified by:
      configureEndpoint in interface RestServiceSupport
      Parameters:
      defaultRules - default routing rules (also accepts Routing.Builder
      serviceEndpointRoutingRules - actual rules (if different from default) for the service endpoint
    • postConfigureEndpoint

      protected abstract void postConfigureEndpoint(Routing.Rules defaultRules, Routing.Rules serviceEndpointRoutingRules)
      Concrete implementations override this method to perform any service-specific routing set-up.
      Parameters:
      defaultRules - default Routing.Rules to be updated
      serviceEndpointRoutingRules - actual rules (if different from the default ones) to be updated for the service endpoint
    • onShutdown

      protected void onShutdown()
      Logic to run when the service is shut down.
    • context

      protected String context()
      Returns:
      web context
    • logger

      protected Logger logger()
      Returns:
      logger in use by the service