December 2019
Intermediate to advanced
314 pages
6h 51m
English
Our application defines one REST endpoint for each Repository class. We already coded CustomerEndpoint in the previous chapter, which was blissfully unaware of whether it was using storage or not. Therefore, half of the work has already been done. We've only added OrderEndpoint here, which maps CRUD HTTP operations accordingly:
@Path("orders")@ApplicationScoped@Produces("application/json")@Consumes("application/json")public class OrderEndpoint { @Inject OrderRepository orderRepository; @Inject CustomerRepository customerRepository; @GET public List<Orders> getAll(@QueryParam("customerId") Long customerId) { return orderRepository.findAll(customerId); } @POST @Path("/{customer}") public Response create(Orders order, ...
Read now
Unlock full access