2
Well I have a question about standardization in the creation of Rest endpoints.
According to Vraptor documentation I can set the request path using the annotation > @Path("/paciente-api")
here at the company this is the standard , but I have noticed some classes where the path ends with / , what a difference it would make in the end?
Requests are also noted, for example> @Get("/")
,
here’s where my biggest question goes,
following this logic my request would be a GET to localhost:8080/system/patient-api/ , until then everything ok, but when I have to send parameters the STATUS CODE is 405, because this happens is an error in my backend or the request ?
I noticed that the request ignored / when it went with parameters, leaving the url like this : http://localhost:8080/system/patient-api? name=xxx , when I put / at the end of the path the request finds its path. , but I get this question about good practices when creating a Rest api. Where is my error, in the documentation that should have been clear, or in the standardization of the address, with or without /, understand?
– Isaías de Lima Coelho
It’s not enough to be so much Vraptor, because whenever we talk about REST, we’re basically talking about it. REST we will usually use the correct HTTP methods (GET, POST, PUT, DELETE), but Vraptor, by own experience, understands very well GET and POST, so I turn around with them only. In general, if I don’t want to update use information get, if I don’t use post.
– Eduardo Santos
As for the routes I use, for example: (get) /users - list users (get) /users/1 - detail user (post) /users - create user (get) /users/1/edit - update user (post) /users/edit - update user (here would be put, but vraptor has to pass an extra parameter to be put, this gives problem when sending file, so never use) (get ) /users/1/remove - remove user
– Eduardo Santos
if I need to pick up a user’s groups I’ll use route /users/1/groups and so on... I don’t know if I’m getting to the part you’re questioning, anything tells me
– Eduardo Santos