1
I have been studying the operation of REST Apis in Java and came across two different didactics. In one of them the teacher placed the notes in the definition of the class, this way:
@Path("imoveis")
@Consumes(MediaType.APPLICATION_JSON + ";charset=utf-8")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public class .....
and in another teaching the teacher placed the notes specifically on top of each method, in this way:
@GET
@Consumes(MediaType.APPLICATION_JSON + ";charset=utf-8")
@Produces(MediaType.APPLICATION_JSON + ";charset=utf-8")
public ......
I would like to know the most correct way to declare these annotations, what are the advantages and disadvantages of each of them.
In my case I had some methods that did not consume or return data, some methods that just returned, and also some that consumed and returned, so I was confused.
– Eduardo Mior
@Eduardo This is the same idea, usually settings that are most used by all methods tend to stay in class, and the methods specialize as needed
– nullptr
aa yes, now I understand.
– Eduardo Mior