class DiscoveryServerController {

	private final KubernetesInformerReactiveDiscoveryClient reactiveDiscoveryClient;

	public DiscoveryServerController(KubernetesInformerReactiveDiscoveryClient reactiveDiscoveryClient) {
		this.reactiveDiscoveryClient = reactiveDiscoveryClient;
	}

	@GetMapping("/apps")
	public Flux<Service> apps() {<FILL_FUNCTION_BODY>}

	@GetMapping("/apps/{name}")
	public Flux<ServiceInstance> appInstances(@PathVariable String name) {
		return reactiveDiscoveryClient.getInstances(name);
	}

	/**
	 * use the "appInstanceNonDeprecated" instead.
	 */
	@Deprecated(forRemoval = true)
	@GetMapping("/app/{name}/{instanceId}")
	public Mono<ServiceInstance> appInstance(@PathVariable String name, @PathVariable String instanceId) {
		return innerAppInstance(name, instanceId);
	}

	@GetMapping("/apps/{name}/{instanceId}")
	Mono<ServiceInstance> appInstanceNonDeprecated(@PathVariable String name, @PathVariable String instanceId) {
		return innerAppInstance(name, instanceId);
	}

	private Mono<ServiceInstance> innerAppInstance(String name, String instanceId) {
		return reactiveDiscoveryClient.getInstances(name)
				.filter(serviceInstance -> serviceInstance.getInstanceId().equals(instanceId)).singleOrEmpty();
	}

}

		return reactiveDiscoveryClient.getServices()
				.flatMap(service -> reactiveDiscoveryClient.getInstances(service).collectList()
						.flatMap(serviceInstances -> Mono.just(new Service(service,
								serviceInstances.stream().map(x -> (DefaultKubernetesServiceInstance) x).toList()))));
	
<no_super_class>