Giter VIP home page Giter VIP logo

Comments (1)

polishq avatar polishq commented on August 13, 2024

Hi @igorgiovannini , thanks for the question!

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.

from reviews-and-ratings.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.