I am not sure if it is exactly what you are looking for - we came up with an IndexController that renders a response containing all the Controllers that are annotated with ExposesResourceFor in HATEOAS style. So we get entry points to the collection resource for every controller.
You could do something similar with your controllers annotated with RestController or RequestMapping.
@RestController
@RequestMapping(path = "/", produces = { "application/hal+json", "application/json" })
public class IndexController {
private final Set<Class<?>> entitiesWithController;
private EntityLinks entityLinks;
private RelProvider relProvider;
@Autowired
public IndexController(ListableBeanFactory beanFactory, EntityLinks entityLinks, RelProvider relProvider) {
this.entityLinks = entityLinks;
this.relProvider = relProvider;
Map<String, Object> beansWithExposesResourceForAnnotation = beanFactory.getBeansWithAnnotation(ExposesResourceFor.class);
entitiesWithController = beansWithExposesResourceForAnnotation.values().stream()
.map(o -> o.getClass().getAnnotation(ExposesResourceFor.class).value()).collect(Collectors.toSet());
}
@RequestMapping(method = GET)
public ResponseEntity<ControllerLinksResource> getControllerLinks() {
ControllerLinksResource controllerLinksResource = new ControllerLinksResource();
entitiesWithController.forEach(entityClass -> controllerLinksResource //
.add(entityLinks.linkToCollectionResource(entityClass) //
.withRel(relProvider.getCollectionResourceRelFor(entityClass))));
return ResponseEntity.ok(controllerLinksResource);
}
}