I learned that writing @Consumes
and @Produces
annotations on every endpoint is good programming. However, if I declare the type in the endpoint, do I still need the annotation?
What is good programming?
@GET
@Consumes(MediaType.APPLICATION_JSON)
@Produces("application/pdf") // Content type declared in annotation
@Path(GET_BILL_FOR_SYSTEM)
public Response getBillForTheSystem(@QueryParam(value = "year") Long year) {
return Response.ok( billSheetService.getBillForTheSystem(year) )
.type( "application/pdf" ) // Content type declared in response builder
.header( "Content-Disposition", "attachment; filename=\"BillForTheSystem.pdf\"" )
.build();
}