Internal Requests To Restful Api?


(Phazei) #1

When I build a web application, it often also has a mobile component, so a RESTful API is always used.

Now for the admin console, and any other web based component on the site, rather than re-implementing the RESTful API, we use it internally for the site functionality and for dynamic AJAX driven sites.

This leads to lots of internal requests to different API endpoints, sometimes a few at once for perhaps creating a “vendor” type user, first there’d be a call to POST /api/vendor, and within /api/vendor it would create a user account with POST /api/user.

Doing external requests to itself via curl involves a lot of overhead, like re-instantiating a new DB instance, and the entire stack PHP stack really. An internal request would already have most of the components loaded, so would be much quicker.

From the direction my development’s gone, it seems a RESTful driven site really drives the need for internal requests.

I didn’t see anyway to call an API request in the docs, is there a way?


GraphQL support planned?
(Schmunk) #2

I thought about the same thing. It would be great to get more feedback about this.

CC: @CeBe @samdark


#3

This is a question of application design. If your API controllers are basic wrappers around the model and most of the functionality lies in the model then you do not need to call the API request to perform some task. If however most of your logic is in the controller it might be wise to refactor this to place the functionality in another place and call that place from API controller and backend controller.