io.micronaut.http.annotation.Get Java Examples
The following examples show how to use
io.micronaut.http.annotation.Get.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FlashBriefingsController.java From micronaut-aws with Apache License 2.0 | 5 votes |
@Get // <1> public List<FlashBriefingItem> index() { return flashBriefingRepository.find() .stream() .filter(item -> validator.validate(item).isEmpty()) // <2> .sorted() // <3> .limit(5) // <4> .collect(Collectors.toList()); }
Example #2
Source File: MusicController.java From kyoko with MIT License | 5 votes |
@Get("/{id}/queue") public Single<HttpResponse> queue(@RequestAttribute("session") Session session, long id) { if (!session.hasGuild(id)) { return Single.just(ErrorResponse.get(ErrorCode.UNKNOWN_GUILD)); } return channel.send(new JsonObject().put("cmd", "queue").put("guild", id)) .singleOrError() .timeout(10, TimeUnit.SECONDS) .flatMap(reply -> Single.<HttpResponse>just(HttpResponse.ok(reply.encode()))) .onErrorResumeNext(err -> Single.just(HttpResponse.ok("{\"queue\":[],\"repeating\":false}"))); }
Example #3
Source File: StatsController.java From kyoko with MIT License | 5 votes |
@Get("/guilds") public Single<String> guilds() { return guildCounts.valueIterator() .reduce(Integer::sum) .map(count -> new JsonObject() .put("count", count) .encode()).toSingle(); }
Example #4
Source File: AuthController.java From kyoko with MIT License | 5 votes |
@Get("/oauth2exchange") Single<HttpResponse> oauth2exchange(@Nullable String code, @Nullable Boolean bot) { var scope = "identify guilds" + (bot != null && bot ? " bot" : ""); return sessionManager.exchangeCode(code, Settings.instance().apiUrls().get("redirect"), scope) .switchIfEmpty(Maybe.error(new NoSuchElementException("no element returned"))) .doOnError(err -> logger.error("Error while exchanging OAuth2 code!", err)) .flatMapSingle(session -> Single.<HttpResponse>just(HttpResponse.ok(new OAuth2ExchangeResponse(session.getToken())))) .onErrorReturnItem(ErrorResponse.get(ErrorCode.INVALID_OAUTH2_CODE)); }
Example #5
Source File: UserController.java From kyoko with MIT License | 5 votes |
@Get("/guilds/{id}") Single<HttpResponse> guild(@RequestAttribute("session") Session session, long id) { if (!session.hasGuild(id)) { return Single.just(ErrorResponse.get(ErrorCode.UNKNOWN_GUILD)); } return Flowable.fromFuture(Main.getCatnip().rest().guild() .getGuild(String.valueOf(id)) .thenApply(KGuildExt::new) .toCompletableFuture()) .singleOrError() .flatMap(guild -> Single.<MutableHttpResponse<?>>just(HttpResponse.ok(guild)) .onErrorReturn(err -> ErrorResponse.get(ErrorCode.UNKNOWN_GUILD))); }
Example #6
Source File: GraphQLController.java From micronaut-graphql with Apache License 2.0 | 5 votes |
/** * Handles GraphQL {@code GET} requests. * * @param query the GraphQL query * @param operationName the GraphQL operation name * @param variables the GraphQL variables * @param httpRequest the HTTP request * @return the GraphQL response */ @Get(produces = APPLICATION_JSON, single = true) public Publisher<String> get( @QueryValue("query") String query, @Nullable @QueryValue("operationName") String operationName, @Nullable @QueryValue("variables") String variables, HttpRequest httpRequest) { // https://graphql.org/learn/serving-over-http/#get-request // // When receiving an HTTP GET request, the GraphQL query should be specified in the "query" query string. // For example, if we wanted to execute the following GraphQL query: // // { // me { // name // } // } // // This request could be sent via an HTTP GET like so: // // http://myapi/graphql?query={me{name}} // // Query variables can be sent as a JSON-encoded string in an additional query parameter called "variables". // If the query contains several named operations, // an "operationName" query parameter can be used to control which one should be executed. return executeRequest(query, operationName, convertVariablesJson(variables), httpRequest); }
Example #7
Source File: HelloWorldMicronautTest.java From micronaut-aws with Apache License 2.0 | 5 votes |
@Get("/multi-cookie") HttpResponse<String> multiCookie() { final MutableHttpResponse<String> response = HttpResponse.ok(BODY_TEXT_RESPONSE); response.cookie(Cookie.of(COOKIE_NAME, COOKIE_VALUE).domain(COOKIE_DOMAIN).path(COOKIE_PATH)) .cookie(Cookie.of(COOKIE_NAME + "2", COOKIE_VALUE + "2").domain(COOKIE_DOMAIN).path(COOKIE_PATH)); return response; }
Example #8
Source File: Database.java From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Get(value = "/fortunes", produces = "text/html;charset=utf-8") public Single<ModelAndView<Map>> fortune() { return dbRepository.fortunes().toList().flatMap(fortunes -> { fortunes.add(new Fortune(0, "Additional fortune added at request time.")); fortunes.sort(comparing(fortune -> fortune.message)); return Single.just(new ModelAndView<>("fortunes", Collections.singletonMap("fortunes", fortunes))); }); }
Example #9
Source File: Database.java From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License | 5 votes |
@Get("/updates") public Single<List<World>> updates(@QueryValue String queries) { Flowable<World>[] worlds = new Flowable[parseQueryCount(queries)]; Arrays.setAll(worlds, i -> dbRepository.findAndUpdateWorld(randomWorldNumber(), randomWorldNumber()).toFlowable() ); return Flowable.merge(Arrays.asList(worlds)).toList(); }
Example #10
Source File: FeaturesClient.java From micronaut-spring with Apache License 2.0 | 4 votes |
@Get("/{name}") FeaturesEndpoint.Feature features(String name);
Example #11
Source File: GreetingClient.java From tutorials with MIT License | 4 votes |
@Get("/{name}") String greet(String name);
Example #12
Source File: JsonSerialization.java From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Get("/") Single<Map> getJson() { Map<String, String> map = new HashMap<>(); map.put("message", "Hello, World!"); return Single.just(map); }
Example #13
Source File: GreetController.java From tutorials with MIT License | 4 votes |
@Get("/{name}") public String greet(String name) { return greetingService.getGreeting() + name; }
Example #14
Source File: AsyncGreetController.java From tutorials with MIT License | 4 votes |
@Get("/{name}") public Single<String> greet(String name) { return Single.just(greetingService.getGreeting() + name); }
Example #15
Source File: HelloController.java From java-docs-samples with Apache License 2.0 | 4 votes |
@Get("/") @Produces(MediaType.TEXT_PLAIN) public String index() { return "Hello World!"; }
Example #16
Source File: PlainText.java From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Get(value = "/", produces = MediaType.TEXT_PLAIN) Single<String> getPlainText() { return Single.just(TEXT); }
Example #17
Source File: Database.java From FrameworkBenchmarks with BSD 3-Clause "New" or "Revised" License | 4 votes |
@Get("/db") public Single<World> db() { return dbRepository.getWorld(randomWorldNumber()); }
Example #18
Source File: PetController.java From database-rider with Apache License 2.0 | 4 votes |
@Get("/{name}") Optional<Pet> byName(String name) { return petRepository.findByName(name); }
Example #19
Source File: StatsController.java From kyoko with MIT License | 4 votes |
@Get("/shards") public Single<List<ShardStatus>> shards() { return shardStatus.valueIterator().toList(); }
Example #20
Source File: UserController.java From kyoko with MIT License | 4 votes |
@Get("/info") User me(@RequestAttribute("session") Session session) { return session.user(); }
Example #21
Source File: PolicyGatewayController.java From micronaut-microservices-poc with Apache License 2.0 | 4 votes |
@Get("/{policyNumber}") GetPolicyDetailsQueryResult get(String policyNumber) { return policyClient.get(policyNumber); }
Example #22
Source File: FeaturesClient.java From micronaut-spring with Apache License 2.0 | 4 votes |
@Get("/") Map<String, FeaturesEndpoint.Feature> features();
Example #23
Source File: TestClient.java From micronaut-spring with Apache License 2.0 | 4 votes |
@Get("/") String hello();
Example #24
Source File: GetMappingAnnotationMapper.java From micronaut-spring with Apache License 2.0 | 4 votes |
@Override protected AnnotationValueBuilder<?> newBuilder(HttpMethod httpMethod, AnnotationValue<Annotation> annotation) { return AnnotationValue.builder(Get.class); }
Example #25
Source File: ProductGatewayController.java From micronaut-microservices-poc with Apache License 2.0 | 4 votes |
@Get("/{productCode}") public Maybe<ProductDto> get(String productCode) { return client.get(productCode); }
Example #26
Source File: ProductGatewayController.java From micronaut-microservices-poc with Apache License 2.0 | 4 votes |
@Get public Single<List<ProductDto>> getAll() { return client.getAll(); }
Example #27
Source File: PaymentGatewayController.java From micronaut-microservices-poc with Apache License 2.0 | 4 votes |
@Get("/accounts") Collection<PolicyAccountDto> accounts() { return paymentClient.accounts(); }
Example #28
Source File: DocumentsGatewayController.java From micronaut-microservices-poc with Apache License 2.0 | 4 votes |
@Get("/{policyNumber}") FindDocumentsResult find(String policyNumber) { return client.find(policyNumber); }
Example #29
Source File: PolicyGatewayClient.java From micronaut-microservices-poc with Apache License 2.0 | 4 votes |
@Override @Get("/policies/{policyNumber}") GetPolicyDetailsQueryResult get(String policyNumber);
Example #30
Source File: PolicyOperations.java From micronaut-microservices-poc with Apache License 2.0 | 4 votes |
@Get("/{policyNumber}") GetPolicyDetailsQueryResult get(@NotNull String policyNumber);