Skip to content

Commit

Permalink
Distinct generated count method from interface in REST Data with Panache
Browse files Browse the repository at this point in the history
  • Loading branch information
Sgitario committed Jan 23, 2023
1 parent c8a2a45 commit 72b1a5e
Showing 1 changed file with 7 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import static io.quarkus.rest.data.panache.deployment.utils.SignatureMethodCreator.ofType;

import javax.ws.rs.core.Response;
import javax.ws.rs.core.UriInfo;

import io.quarkus.deployment.Capabilities;
import io.quarkus.gizmo.ClassCreator;
Expand Down Expand Up @@ -41,9 +42,9 @@ public CountMethodImplementor(Capabilities capabilities) {
* {@code
* @GET
* @Path("/count")
* public long count() {
* public Response count(UriInfo uriInfo) {
* try {
* return resource.count();
* return Response.ok(resource.count());
* } catch (Throwable t) {
* throw new RestDataPanacheException(t);
* }
Expand Down Expand Up @@ -74,10 +75,13 @@ protected void implementInternal(ClassCreator classCreator, ResourceMetadata res
ResourceProperties resourceProperties, FieldDescriptor resourceField) {
// Method parameters: sort strings, page index, page size, uri info
MethodCreator methodCreator = SignatureMethodCreator.getMethodCreator(RESOURCE_METHOD_NAME, classCreator,
isNotReactivePanache() ? ofType(Response.class) : ofType(Uni.class, Long.class));
isNotReactivePanache() ? ofType(Response.class) : ofType(Uni.class, Long.class),
UriInfo.class);
methodCreator.setParameterNames(new String[] { "uriInfo" });

// Add method annotations
addGetAnnotation(methodCreator);
addContextAnnotation(methodCreator.getParameterAnnotations(0));
addProducesAnnotation(methodCreator, APPLICATION_JSON);
addPathAnnotation(methodCreator, appendToPath(resourceProperties.getPath(RESOURCE_METHOD_NAME), RESOURCE_METHOD_NAME));
addMethodAnnotations(methodCreator, resourceProperties.getMethodAnnotations(RESOURCE_METHOD_NAME));
Expand Down

0 comments on commit 72b1a5e

Please sign in to comment.