/** * @return The current leader address */ @Get(uri = "/status/leader", single = true) Publisher<String> status();
/** * Reads a Key from Consul. See https://www.consul.io/api/kv.html. * * @param key The key to read * @return A {@link Publisher} that emits a list of {@link KeyValue} */ @Get(uri = "/kv/{+key}?recurse", single = true) Publisher<List<KeyValue>> readValues(String key);
/** * Gets all of the registered services. * * @return The {@link NewServiceEntry} instances */ @Get(uri = "/agent/services", single = true) Publisher<Map<String, ServiceEntry>> getServices();
/** * Gets all of the service names and optional tags. * * @return A Map where the keys are service names and the values are service tags */ @Get(uri = "/catalog/services", single = true) Publisher<Map<String, List<String>>> getServiceNames();
/** * Returns the configuration and member information of the local agent. * * @return the {@link LocalAgentConfiguration} instance */ @Get(uri = "/agent/self", single = true) Publisher<LocalAgentConfiguration> getSelf();
/** * Gets all the nodes for the given data center. * * @param datacenter The data center * @return A publisher that emits the nodes */ @Get(uri = "/catalog/nodes?dc={datacenter}", single = true) Publisher<List<CatalogEntry>> getNodes(@NotNull String datacenter);
/** * @return A {@link Publisher} with applications info. */ @SuppressWarnings("WeakerAccess") @Get("/apps") @Produces(single = true) public abstract Publisher<ApplicationInfos> getApplicationInfosInternal();
/** * Obtain a {@link ApplicationInfo} for the given app id. * * @param appId The app id * @return The {@link ApplicationInfo} instance */ @Get(uri = "/apps/{appId}", single = true) Publisher<ApplicationInfo> getApplicationInfo(@NotBlank String appId);
@Get("/list") String list(List<Integer> values) { assert values.stream().allMatch(val -> val instanceof Integer); return "Parameter Value: " + values; }
/** * Obtain a {@link InstanceInfo} for the given app id. * * @param appId The app id * @param instanceId The instance id (this is the value of {@link InstanceInfo#getId()}) * @return The {@link InstanceInfo} instance */ @Get(uri = "/apps/{appId}/{instanceId}", single = true) Publisher<InstanceInfo> getInstanceInfo(@NotBlank String appId, @NotBlank String instanceId);
@Get("/optional-list") String optionalList(Optional<List<Integer>> values) { if (values.isPresent()) { assert values.get().stream().allMatch(val -> val instanceof Integer); return "Parameter Value: " + values.get(); } else { return "Parameter Value: none"; } } }
@Get public HttpResponse index(String username) { return HttpResponse.ok("Authenticated: " + username); } }
@Get("/greet/{name}") Message greet(String name) { return new Message("Hello " + name); } // end::json[]
@Get("/maybestock/{isbn}") public Maybe<Map> maybestock(String isbn) { return Maybe.empty(); //<2> } }
@Status(HttpStatus.CREATED) @Get(produces = MediaType.TEXT_PLAIN) public String index() { return "success"; } //end::atstatus[]
@Produces(MediaType.TEXT_PLAIN) @Get("/stock/{isbn}") Integer stock(String isbn) { throw new OutOfStockException(); } }
@Produces(MediaType.TEXT_PLAIN) @Get("/stock/{isbn}") Integer stock(String isbn) { throw new OutOfStockException(); } }
@Get("/custom-headers") public HttpResponse customHeaders() { return HttpResponse.ok("abc").contentType("text/plain").contentLength(7); } }
@Get("/{name}") public HttpResponse<Pet> get(String name, @Header("X-Pet-Client") String clientId) { Pet pet = new Pet(); pet.setName(name); pet.setAge(Integer.valueOf(clientId)); return HttpResponse.ok(pet) .header("X-Pet-Client", clientId); } }
@Get(value = "/headlines", produces = MediaType.TEXT_EVENT_STREAM) // <1> Flux<Event<Headline>> streamHeadlines() { return Flux.<Event<Headline>>create((emitter) -> { // <2> Headline headline = new Headline(); headline.setText("Latest Headline at " + ZonedDateTime.now()); emitter.next(Event.of(headline)); emitter.complete(); }).repeat(100) // <3> .delayElements(Duration.ofSeconds(1)); // <4> } // end::streaming[]