Skip to content

Commit

Permalink
Ensure that RESTEasy Reactive Links works with async return types
Browse files Browse the repository at this point in the history
Fixes: #25189
  • Loading branch information
geoand committed Apr 27, 2022
1 parent fc1c550 commit 3b6136b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.quarkus.resteasy.reactive.links.deployment;

import java.time.Duration;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
Expand All @@ -15,6 +16,7 @@
import io.quarkus.resteasy.reactive.links.InjectRestLinks;
import io.quarkus.resteasy.reactive.links.RestLink;
import io.quarkus.resteasy.reactive.links.RestLinkType;
import io.smallrye.mutiny.Uni;

@Path("/records")
public class TestResource {
Expand All @@ -29,8 +31,8 @@ public class TestResource {
@Produces(MediaType.APPLICATION_JSON)
@RestLink(entityType = TestRecord.class, rel = "list")
@InjectRestLinks
public List<TestRecord> getAll() {
return RECORDS;
public Uni<List<TestRecord>> getAll() {
return Uni.createFrom().item(RECORDS).onItem().delayIt().by(Duration.ofMillis(100));
}

@GET
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public void setRestLinkData(RestLinkData restLinkData) {

@Override
public void handle(ResteasyReactiveRequestContext context) {
context.requireCDIRequestScope();
Response response = context.getResponse().get();
for (Link link : getLinks(response)) {
response.getHeaders().add("Link", link);
Expand Down

0 comments on commit 3b6136b

Please sign in to comment.