Я использую здоровье привода весенней загрузки с весенним чванством лисы в проекте весенней загрузки. Я использую ниже в своем классе Application.java.
@Autowired
private HealthAggregator healthAggregator;
@Autowired
private Map<String, HealthIndicator> healthIndicators;
@Bean
public com.health.TestMeHealthEndpoint getHealthEndpoint() {
return new com.health.TestMeHealthEndpoint(healthAggregator, healthIndicators);
}
@Bean
public Docket testMeApi() {
return new Docket(DocumentationType.SWAGGER_2).useDefaultResponseMessages(false).apiInfo(apiInfo()).select()
.paths(testMePaths()).build();
}
private Predicate<String> testMePaths() {
return or(regex("/api/myservice1"), regex("/health"));
}
Но когда я проверяю пользовательский интерфейс swagger, я вижу несколько конечных точек работоспособности со всеми типами методов http, включая POST, DELETE, OPTIONS и т. д. Для myservice1, который реализуется в контроллере REST, он отображает только метод GET.
TestMeHealthEndpoint расширяет AbstractEndpoint и переопределяет метод вызова с пользовательской информацией о работоспособности.
Я только хочу увидеть, является ли метод GET для маршрута здоровья?
Добавьте источник TestMeHealthEndpoint:
@ConfigurationProperties(prefix = "endpoints.health", ignoreUnknownFields = true)
public class TestMeHealthEndpoint extends AbstractEndpoint<Health> {
//Some getter and setters for api name , version etc
public TestMeHealthEndpoint (final HealthAggregator healthAggregator,
final Map<String, HealthIndicator> healthIndicators) {
super("health", false);
final CompositeHealthIndicator healthIndicator = new CompositeHealthIndicator(healthAggregator);
for (final Map.Entry<String, HealthIndicator> entry : healthIndicators.entrySet()) {
healthIndicator.addHealthIndicator(getKey(entry.getKey()), entry.getValue());
}
this.healthIndicator = healthIndicator;
}
@Override
public Health invoke() {
final Health health = new Health();
health.setStatus(this.healthIndicator.health().getStatus().getCode());
health.setName(this.apiName);
health.setVersion(this.apiVersion);
final UriComponentsBuilder path = ServletUriComponentsBuilder.fromCurrentServletMapping()
.path(this.managementContextPath).pathSegment(this.getId());
health.add(new Link(path.build().toUriString()).withSelfRel());
return health;
}
}