Trait for finding controller actions by HTTP method used on the request. Handy for building CRUD based Webservices. Can be used alongside the default action handling.
- Silverstripe 4.x
composer require level51/silverstripe-find-http-action
- Flush config (
flush=all
)
use Level51\FindHTTPAction\FindHTTPAction;
use SilverStripe\Control\Controller;
class MyCRUDController extends Controller {
use FindHTTPAction;
...
private static $url_handlers = [
'foo/$id' => [
'GET' => 'getFooRecords',
'POST' => 'createFooRecord',
'PUT' => 'updateFooRecord',
'DELETE' => 'deleteFooRecord'
],
'bar/$id!' => [
'PUT' => 'updateBarRecord'
],
'about' => 'myRegularAction
];
}
- Julian Scheuchenzuber js@lvl51.de