I working with Luracast Restler API frame work and cannot figure out how to specify a default behavior for the root directory. For example:
webroot/user - will invoke the class User method get() by default
webroot/ - return a 404
Is there a catch all class/method for the base path?
on your index.php (gateway)
require_once '../../restler/restler.php';
require_once 'say.php';
$r = new Restler();
//blank string as the second param removes class_name from the URL
$r->addAPIClass('Say','');
$r->handle();
This makes Say as the default class, mapped to the root
Next on your API class (Say) define an index method, it can also be a get method
class Say {
function index($to='world') {
return "Hello $to!";
}
}
then calling
GET index.php
will return Hello World!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With