With Slim App get/post/patch etc functions, I can register routes and Slim will invoke them automatically.
My question is how can I invoke those routes from my code?
What I want to do is to batch the requests.
For example, I may have routes such like
get(’/a’);
get(’/b’);
Then I may have a get(’/batch’), the batch route parses a JSON data to extract a sequence of sub request such as /a and /b, then it invoke the routes on /a and /b manually.
@SVL, @geggleto, @damianopetrungaro, thanks for your advice.
But I can’t see the issue in the design of “batch” idea.
Assume I have API f1 and f2, and 3 pages A, B, C. A uses f1, B uses f2, and C uses both f1 and f2. In page C, instead of sending two requests, I would like to batch f1 and f2 in one single request to save HTTP connections.
Thoughts?
I mean, yes, I do provide two methods f1 and f2, but whenever the client app needs both f1 and f2, I want to batch them in a single HTTP request. The sever still calls the handlers of f1 and f2 respectively. My purpose to do it is to save HTTP connections (1 connection for both f1 and f2 instead of 2 for f1 and f2).
If anyone in doubt googles “restful batch”, there are pretty some discussion on this topic.
Any way, since Slim is a framework, I wish it keeps the subRequest API because it’s useful even though the Slim developers don’t think so.