In Magento 2, a REST endpoint is a PHP interface and 6 lines of XML, and the method's docblock decides what the endpoint accepts. In Laravel it's a route, a controller and a resource class, and the contract lives wherever you write it down.
Magento: a route points at an interface
webapi.xml maps a URL and an HTTP method to a method on a service contract, Magento's name for a PHP interface that a module publishes as its API. The core's own order endpoint is exactly that: GET /V1/orders/:id calls OrderRepositoryInterface::get() , and the <resource> line names the permission the caller needs. Without a token it answers 401.
<route url = "/V1/orders/:id" method = "GET" > <service class = "Magento\Sales\Api\OrderRepositoryInterface" method = "get" /> <resources> <resource ref = "Magento_Sales::actions_view" /> </resources> </route>
Enter fullscreen mode
Exit fullscreen mode
There's no controller of yours in between.…