You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is there a technical need to handle the various cases manually, instead of taking advantage of the facilities offered by the framework (i.e. using annotations)?
I think for example to the query strings, or the payload of a POST request.
You can expose the same endpoint, with different action methods and HTTP actions of course.
Thanks! 😄
The text was updated successfully, but these errors were encountered:
If I understand correctly, you want to know why we do not take advantage of annotations like [HttpPut], [HttpGet], and [HttpDelete] to handle different actions for the same endpoint. And also why we do not use [FromBody] to get the payload automatically parsed.
We do not use annotations to define the path a controller method supports because we use our dotnet/services.json file to define the routes. This is because before reaching our app, the requests will reach the VTEX IO Router, so both of them need to understand the same route definitions (otherwise we would need to synchronize the routes definitions, which is error-prone).
The service.json route definition associates a controller method to a path. Having multiple controller methods for the same path would be possible only if we had the HTTP action to combine with the path in the route definition.
That said, we can use these annotations. The problem is that we need to use different endpoints for each action (one for a PUT, one for a GET, and another one for a DELETE, for instance). Having one controller method per action, you can also use [FromBody], [FromQuery], and cache annotations as you would do in any .Net app.
In this particular example, we want to be RESTful and have one endpoint to handle multiple HTTP actions, so we need to have only one controller method and check the actions and bodies when receiving the requests.
Long story short, we do not support RESTful APIs more easily because our route definitions do not have the HTTP actions.
In our enterprise we are currently evaluating VTEX.
Having a look at the source code of this extension, I noticed you handle manually various stuffs for a specific endpoint (see https://github.com/vtex-apps/reviews-and-ratings/blob/master/dotnet/Controllers/RoutesController.cs).
Is there a technical need to handle the various cases manually, instead of taking advantage of the facilities offered by the framework (i.e. using annotations)?
I think for example to the query strings, or the payload of a POST request.
You can expose the same endpoint, with different action methods and HTTP actions of course.
Thanks! 😄
The text was updated successfully, but these errors were encountered: