or run

tessl search
Log in

Version

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/io.quarkus/quarkus-resteasy-reactive@3.15.x

docs

index.md
tile.json

tessl/maven-io-quarkus--quarkus-resteasy-reactive

tessl install tessl/maven-io-quarkus--quarkus-resteasy-reactive@3.15.0

A Jakarta REST implementation utilizing build time processing and Vert.x for high-performance REST endpoints with reactive capabilities in cloud-native environments.

conditional-endpoints.mddocs/reference/

Conditional Endpoints

Quarkus REST provides the @EndpointDisabled annotation to conditionally enable or disable endpoints based on configuration properties.

Import

import io.quarkus.resteasy.reactive.server.EndpointDisabled;

@EndpointDisabled

Conditionally disables an endpoint based on a configuration property value.

@Target({ElementType.TYPE, ElementType.METHOD})
@Retention(RetentionPolicy.RUNTIME)
public @interface EndpointDisabled {
    String name();                           // Config property name
    String stringValue() default "";         // Expected value for disabling
    boolean disableIfMissing() default false;  // Disable if property missing
}

Usage

Disable Based on Property Value

@Path("/admin")
@EndpointDisabled(name = "admin.enabled", stringValue = "false")
public class AdminResource {
    // All endpoints disabled when admin.enabled=false

    @GET
    public List<User> listUsers() {
        return adminService.listUsers();
    }
}

Configuration in application.properties:

admin.enabled=false  # Disables AdminResource endpoints

Disable If Property Missing

@Path("/experimental")
@EndpointDisabled(name = "features.experimental", stringValue = "true", disableIfMissing = true)
public class ExperimentalResource {
    // Disabled unless features.experimental=true is explicitly set

    @GET
    public Data getExperimental() {
        return experimentalService.getData();
    }
}

Method-Level Disabling

@Path("/api")
public class ApiResource {

    @GET
    @Path("/stable")
    public Data getStable() {
        return dataService.getStable();
    }

    @GET
    @Path("/beta")
    @EndpointDisabled(name = "features.beta", stringValue = "false")
    public Data getBeta() {
        // Only this endpoint disabled when features.beta=false
        return dataService.getBeta();
    }
}

Feature Flags

@Path("/features")
public class FeatureResource {

    @GET
    @Path("/new-feature")
    @EndpointDisabled(name = "feature.new-feature.enabled", stringValue = "false", disableIfMissing = true)
    public Response getNewFeature() {
        // Disabled by default, must be explicitly enabled
        return Response.ok(newFeatureService.getData()).build();
    }

    @GET
    @Path("/legacy-feature")
    @EndpointDisabled(name = "feature.legacy.disabled", stringValue = "true")
    public Response getLegacyFeature() {
        // Enabled by default, can be disabled
        return Response.ok(legacyService.getData()).build();
    }
}

Environment-Specific Endpoints

@Path("/debug")
@EndpointDisabled(name = "app.environment", stringValue = "production")
public class DebugResource {
    // Disabled in production environment

    @GET
    @Path("/info")
    public Map<String, Object> getDebugInfo() {
        return debugService.getInfo();
    }
}

Configuration:

# development
app.environment=development  # DebugResource enabled

# production
app.environment=production   # DebugResource disabled

Multiple Conditions

Apply to both class and method for compound conditions:

@Path("/internal")
@EndpointDisabled(name = "internal.api.enabled", stringValue = "false")
public class InternalResource {
    // All endpoints require internal.api.enabled=true

    @GET
    @Path("/admin")
    @EndpointDisabled(name = "internal.admin.enabled", stringValue = "false")
    public Data getAdminData() {
        // Requires both internal.api.enabled=true AND internal.admin.enabled=true
        return internalService.getAdminData();
    }

    @GET
    @Path("/metrics")
    public Data getMetrics() {
        // Only requires internal.api.enabled=true
        return internalService.getMetrics();
    }
}

Behavior

When an endpoint is disabled:

  • Returns 404 Not Found (as if the endpoint doesn't exist)
  • Not included in OpenAPI documentation
  • Not registered in the routing table
  • Zero runtime overhead (build-time optimization)
@Path("/disabled")
@EndpointDisabled(name = "endpoint.enabled", stringValue = "false")
public class DisabledResource {
    @GET
    public String get() {
        return "This won't be reached";
    }
}

// With endpoint.enabled=false:
// GET /disabled -> 404 Not Found

Build-Time vs Runtime

@EndpointDisabled is evaluated at build time based on the configuration:

@Path("/endpoint")
@EndpointDisabled(name = "my.feature", stringValue = "false")
public class MyResource {
    @GET
    public String get() {
        return "data";
    }
}

Build time configuration (in application.properties):

my.feature=false  # Endpoint excluded from build

To change at runtime, rebuild the application or use profiles.

Profiles

Combine with Quarkus profiles for environment-specific behavior:

# application.properties
%dev.debug.enabled=true
%test.debug.enabled=true
%prod.debug.enabled=false
@Path("/debug")
@EndpointDisabled(name = "debug.enabled", stringValue = "false")
public class DebugResource {
    // Automatically enabled in dev/test, disabled in prod
}

Comparison with Security Annotations

ApproachUse CaseEvaluated
@EndpointDisabledFeature flags, environment configBuild time
@RolesAllowedUser authorizationRuntime
@DenyAllAlways forbiddenRuntime

Use @EndpointDisabled for feature toggles and environment configuration, not for security:

// Feature toggle (correct use)
@EndpointDisabled(name = "beta.enabled", stringValue = "false")

// Security (use @RolesAllowed instead)
@RolesAllowed("ADMIN")

Testing Disabled Endpoints

In tests, override configuration to enable endpoints:

@QuarkusTest
@TestProfile(EnableAllProfile.class)
class DisabledEndpointTest {

    @Test
    void testDisabledEndpoint() {
        given()
            .when().get("/disabled")
            .then()
            .statusCode(200);  // Enabled by test profile
    }
}

public class EnableAllProfile implements QuarkusTestProfile {
    @Override
    public Map<String, String> getConfigOverrides() {
        return Map.of("endpoint.enabled", "true");
    }
}

Documentation

Disabled endpoints are excluded from generated OpenAPI documentation:

@Path("/api")
public class ApiResource {

    @GET
    @Path("/public")
    public String getPublic() {
        return "public";  // Appears in OpenAPI
    }

    @GET
    @Path("/private")
    @EndpointDisabled(name = "private.enabled", stringValue = "false")
    public String getPrivate() {
        return "private";  // Excluded from OpenAPI when disabled
    }
}