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
Nested ClassesModifier and TypeClassDescriptionstatic classHelidonFeatureSupport.Builder<B extends HelidonFeatureSupport.Builder<B,T>, T extends HelidonFeatureSupport> Abstract implementation of aBuilderfor the service. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedHelidonFeatureSupport(System.Logger logger, HelidonFeatureSupport.Builder<?, ?> builder, String serviceName) Shared initialization for new service support instances.protectedHelidonFeatureSupport(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 voidbooleanenabled()When a service is not enabled, it can be omitted from registration with server.protected System.Loggerlogger()protected voidpostSetup(HttpRouting.Builder defaultRouting, HttpRouting.Builder featureRouting) This can be used to register services, filters etc.final voidsetup(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, waitMethods inherited from interface io.helidon.webserver.servicecommon.FeatureSupport
service, setupMethods inherited from interface io.helidon.webserver.http.HttpFeature
get, socket, socketRequiredMethods 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- theLoggerfor 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:
setupin interfaceFeatureSupport- Parameters:
defaultRouting- default routing rules (also acceptsHttpRouting.BuilderfeatureRouting- actual rules (if different from default) for the service endpoint
-
context
Description copied from interface:FeatureSupportWeb context of this service.- Specified by:
contextin interfaceFeatureSupport- Returns:
- context path to be registered
-
configuredContext
Description copied from interface:FeatureSupportWeb context of this service as configured (may not contain leading slash).- Specified by:
configuredContextin interfaceFeatureSupport- Returns:
- context path exactly as configured
-
enabled
public boolean enabled()Description copied from interface:FeatureSupportWhen a service is not enabled, it can be omitted from registration with server.- Specified by:
enabledin interfaceFeatureSupport- Returns:
truefor 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- defaultHttpRulesto be updatedfeatureRouting- actual rules (if different from the default ones) to be updated for the service endpoint
-
logger
-