4 import org.springframework.http.MediaType;
5 import org.springframework.web.bind.annotation.GetMapping;
6 import org.springframework.web.bind.annotation.RequestParam;
7 import org.springframework.web.reactive.function.client.WebClientResponseException;
8 import org.springframework.web.reactive.function.client.WebClientResponseException.NotFound;
9 import reactor.core.publisher.Mono;
13 * Fetches and returns data from a remote-webserver.
16 @org.springframework.web.bind.annotation.RestController
17 public class RestController
19 RemoteContentService service;
22 public RestController(RemoteContentService service)
24 this.service = service;
28 @GetMapping(path = { "", "/" }, produces = MediaType.TEXT_PLAIN_VALUE)
29 public Mono<String> fetch(@RequestParam String path)
36 if(t.getClass().equals(NotFound.class))
38 if(!(t instanceof WebClientResponseException))
41 WebClientResponseException.create(
43 "Internal Server Error - Cause: " + t.getMessage(),
50 WebClientResponseException.create(
52 "Service Unavailable - Cause: " + t.getMessage(),