Module io.helidon.servicecommon
Class HelidonFeatureSupport
java.lang.Object
io.helidon.webserver.servicecommon.HelidonFeatureSupport
- All Implemented Interfaces:
HttpFeature
,ServerLifecycle
,FeatureSupport
,Supplier<HttpFeature>
- Direct Known Subclasses:
MicrometerFeature
,PrometheusSupport
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.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
HelidonFeatureSupport.Builder<B extends HelidonFeatureSupport.Builder<B,
T>, T extends HelidonFeatureSupport> Abstract implementation of aBuilder
for the service. -
Constructor Summary
ModifierConstructorDescriptionprotected
HelidonFeatureSupport
(System.Logger logger, HelidonFeatureSupport.Builder<?, ?> builder, String serviceName) Shared initialization for new service support instances.protected
HelidonFeatureSupport
(System.Logger logger, RestServiceSettings restServiceSettings, String serviceName) -
Method Summary
Modifier and TypeMethodDescriptionWeb context of this service as configured (may not contain leading slash).context()
Web context of this service.protected void
boolean
enabled()
When a service is not enabled, it can be omitted from registration with server.protected System.Logger
logger()
protected void
postSetup
(HttpRouting.Builder defaultRouting, HttpRouting.Builder featureRouting) This can be used to register services, filters etc.final void
setup
(HttpRouting.Builder defaultRouting, HttpRouting.Builder featureRouting) Configures service endpoint on the provided routing rules.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.helidon.webserver.servicecommon.FeatureSupport
service, setup
Methods inherited from interface io.helidon.webserver.http.HttpFeature
get, socket, socketRequired
Methods inherited from interface io.helidon.webserver.ServerLifecycle
afterStop, beforeStart
-
Constructor Details
-
HelidonFeatureSupport
protected HelidonFeatureSupport(System.Logger logger, HelidonFeatureSupport.Builder<?, ?> builder, String serviceName) Shared initialization for new service support instances.- Parameters:
logger
- theLogger
for the concrete service support instancebuilder
- builder for the service support instance.serviceName
- name of the service
-
HelidonFeatureSupport
protected HelidonFeatureSupport(System.Logger logger, RestServiceSettings restServiceSettings, String serviceName)
-
-
Method Details
-
setup
Configures service endpoint on the provided routing rules. This method just adds the endpoint path (as defaulted or configured). This method is exclusive toFeatureSupport.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 interfaceFeatureSupport
- Parameters:
defaultRouting
- default routing rules (also acceptsHttpRouting.Builder
featureRouting
- actual rules (if different from default) for the service endpoint
-
context
Description copied from interface:FeatureSupport
Web context of this service.- Specified by:
context
in interfaceFeatureSupport
- Returns:
- context path to be registered
-
configuredContext
Description copied from interface:FeatureSupport
Web context of this service as configured (may not contain leading slash).- Specified by:
configuredContext
in interfaceFeatureSupport
- Returns:
- 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 interfaceFeatureSupport
- Returns:
true
for enabled services
-
context
-
postSetup
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). IfFeatureSupport.service()
provides an instance, that instance will be correctly registered with the context root on feature routing.- Parameters:
defaultRouting
- defaultHttpRules
to be updatedfeatureRouting
- actual rules (if different from the default ones) to be updated for the service endpoint
-
logger
-