I searched how to create RESTApi router with htaccess.
GetUser GET /order/[:param]/id|ordernum|client
GetOrderStatuses GET /orders/stauses
OrderAdd POST /order
OrderAccept POST /order/[:id]/accept
OrderCancel POST /order/[:id]/cancel
from /order/ part of REQUEST_URI, api.php knows which class to call, e.g. Order.php
but know how to understand which method of Order class should call to take requested action?
I was thinking of this: first we determine if we got POST or GET request. and we create two arrays to map REQUEST_URI with method.
$get = array(
‘/order/[‘0-9’]/[‘a-zAz’]’ => ‘Create’,
…
);
$post = array(
‘/order/[‘0-9’]/accept’ => ‘Accept’ ,
…
);
Know with POST or GET method and with REQUEST_URI pattern, we know which method to call.
Is it a good practice? somehow I feel No. What is the best way to understand which method to call based on the request in REQUEST_URI?