Class HelidonFeatureSupport

All Implemented Interfaces:
HttpFeature, ServerLifecycle, FeatureSupport, Supplier<HttpFeature>
Direct Known Subclasses:
MicrometerFeature, PrometheusSupport

public abstract class HelidonFeatureSupport extends Object implements FeatureSupport
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 postSetup(HttpRouting.Builder, HttpRouting.Builder) to do any service-specific routing. See also the HelidonFeatureSupport.Builder information for possible additional overrides.

  • Constructor Details

    • HelidonFeatureSupport

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

      protected HelidonFeatureSupport(System.Logger logger, RestServiceSettings restServiceSettings, String serviceName)
  • Method Details

    • setup

      public final void setup(HttpRouting.Builder defaultRouting, HttpRouting.Builder featureRouting)
      Configures service endpoint on the provided routing rules. This method just adds the endpoint path (as defaulted or configured). This method is exclusive to FeatureSupport.setup(io.helidon.webserver.http.HttpRouting.Builder) (e.g. you should not use both, as otherwise you would register the endpoint twice)
      Specified by:
      setup in interface FeatureSupport
      defaultRouting - default routing rules (also accepts HttpRouting.Builder
      featureRouting - actual rules (if different from default) for the service endpoint
    • context

      public String context()
      Description copied from interface: FeatureSupport
      Web context of this service.
      Specified by:
      context in interface FeatureSupport
      context path to be registered
    • configuredContext

      public String configuredContext()
      Description copied from interface: FeatureSupport
      Web context of this service as configured (may not contain leading slash).
      Specified by:
      configuredContext in interface FeatureSupport
      context path exactly as configured
    • enabled

      public boolean enabled()
      Description copied from interface: FeatureSupport
      When a service is not enabled, it can be omitted from registration with server.
      Specified by:
      enabled in interface FeatureSupport
      true for enabled services
    • context

      protected void context(String context)
    • postSetup

      protected void postSetup(HttpRouting.Builder defaultRouting, HttpRouting.Builder featureRouting)
      This can be used to register services, filters etc. on either the default rules (usually the main routing of the web server) and the feature routing (may be the same instance). If FeatureSupport.service() provides an instance, that instance will be correctly registered with the context root on feature routing.
      defaultRouting - default HttpRules to be updated
      featureRouting - actual rules (if different from the default ones) to be updated for the service endpoint
    • logger

      protected System.Logger logger()