Class AddHalMethodImplementor

    • Constructor Detail

      • AddHalMethodImplementor

        public AddHalMethodImplementor​(boolean withValidation,
                                       boolean isResteasyClassic)
    • Method Detail

      • implementInternal

        protected void implementInternal​(io.quarkus.gizmo.ClassCreator classCreator,
                                         ResourceMetadata resourceMetadata,
                                         ResourceProperties resourceProperties,
                                         io.quarkus.gizmo.FieldDescriptor resourceField)
        Expose RestDataResource.add(Object) via HAL JAX-RS method. Generated code looks more or less like this:
         
             @POST
             @Path("")
             @Consumes({"application/json"})
             @Produces({"application/hal+json"})
             public Response addHal(Entity entityToSave) {
                 try {
                     Entity entity = resource.add(entityToSave);
                     HalEntityWrapper wrapper = new HalEntityWrapper(entity);
                     String location = new ResourceLinksProvider().getSelfLink(entity);
                     if (location != null) {
                         ResponseBuilder responseBuilder = Response.status(201);
                         responseBuilder.entity(wrapper);
                         responseBuilder.location(URI.create(location));
                         return responseBuilder.build();
                     } else {
                         throw new RuntimeException("Could not extract a new entity URL");
                     }
                 } catch (Throwable t) {
                     throw new RestDataPanacheException(t);
                 }
             }
         
         
        Specified by:
        implementInternal in class StandardMethodImplementor