Annotation routing
In example
namespace App\ResourcesModule\Presenters; use Nette; use Ublaboo\ApiRouter\ApiRoute; /** * API for managing users * * @ApiRoute( * "/api-router/api/users[/<id>]", * parameters={ * "id"={ * "requirement": "\d+", * "default": 10 * } * }, * priority=1, * presenter="Resources:Users" * ) */ class UsersPresenter extends Nette\Application\UI\Presenter { /** * Get user detail * * @ApiRoute( * "/api-router/api/users/<id>[/<foo>-<bar>]", * parameters={ * "id"={ * "requirement": "\d+" * } * }, * method="GET", * } * ) */ public function actionRead($id, $foo = NULL, $bar = NULL) { $this->sendJson(['id' => $id, 'foo' => $foo, 'bar' => $bar]); } public function actionUpdate($id) { $this->sendJson(['id' => $id]); } public function actionDelete($id) { $this->sendJson(['id' => $id]); } }
Now 3 routes will be created (well, 2, but the one accepts both PUT and DELETE method).
If you don't want to create route with DELETE method, simply remove the UsersPresenter::actionDelete() method.