docs
reference
tessl install tessl/maven-io-quarkus--quarkus-resteasy-reactive@3.15.0A Jakarta REST implementation utilizing build time processing and Vert.x for high-performance REST endpoints with reactive capabilities in cloud-native environments.
Quarkus REST provides the @EndpointDisabled annotation to conditionally enable or disable endpoints based on configuration properties.
import io.quarkus.resteasy.reactive.server.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
}@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@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();
}
}@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();
}
}@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();
}
}@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 disabledApply 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();
}
}When an endpoint is disabled:
@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@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 buildTo change at runtime, rebuild the application or use 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
}| Approach | Use Case | Evaluated |
|---|---|---|
@EndpointDisabled | Feature flags, environment config | Build time |
@RolesAllowed | User authorization | Runtime |
@DenyAll | Always forbidden | Runtime |
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")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");
}
}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
}
}