techjoomla / com_api

API framework for Joomla
http://docs.techjoomla.com/joomla-rest-api/com-api-introduction
GNU General Public License v3.0
123 stars 97 forks source link

Add a Joomla router #44

Closed coolbung closed 7 years ago

coolbung commented 7 years ago

Add a router so that the following routes are supported. Users will not create a menu for com_api so the default Joomla routes will be used. If a plugin uses the id or alias parameters in querystring those can be rewritten by the route. All other query params will stay visible in the URL.

Basic route for app & resource

/components/api/:app/:resource

The URL ?option=com_api&app=<appname>&resource=<resource> will be written as the above route.

Add support for id / slug

/components/api/:app/:resource/:id or /components/api/:app/:resource/:alias

The URL ?option=com_api&app=<appname>&resource=<resource>&id=<id> will be written as the above route. In case the last segment is a non-integer it will be mapped as the alias param i.e. ?option=com_api&app=<appname>&resource=<resource>&alias=<alias>

coolbung commented 7 years ago

Decided against the alias since it will make the parameter's conversion to a querystring unpredictable. Only id is supported.