The title says it all.
Is there any request type annotation to do that?
Or is it enough to annotate the method with all the required types like @POST, @GET?
The title says it all.
Is there any request type annotation to do that?
Or is it enough to annotate the method with all the required types like @POST, @GET?
Copyright © 2021 Jogjafile Inc.
Short answer:
Yes, you can annotate a method with
@OPTIONS,@HEAD,@GET,@POST,@PUT,@DELETEand the resource method should be called on all of these methods.Long answer:
You should not! Every HTTP method has it's semantic. A
@GETis a 'safe' method because it is intended for reading a resource.@POSTand@DELETEfor instance are 'unsafe' because they change the state of a resource.The web works because people follow these rules. A web-crawler knows that he can safely do a
@GETon every URI he knows. He would never do a@DELETEon a URI. If your method changes something on a@GETyou might get problems.Find more answers why you should not here: Rest Services conventions.