Direct routing

In example

Same configuration as the annotation one:

namespace App;

use Nette;
use Nette\Application\Routers\RouteList;
use Nette\Application\Routers\Route;
use Ublaboo\ApiRouter\ApiRoute;

class RouterFactory
{

	/**
	 * @return Nette\Application\IRouter
	 */
	public function createRouter()
	{
		$router = new RouteList;

		$router[] = new ApiRoute('/api-router/api/users[/<id>]', 'Resources:Users', [
			'parameters' => [
				'id' => ['requirement' => '\d+', 'default' => 10]
			],
			'priority' => 1
		]);

		$router[] = new ApiRoute('/api-router/api/users/<id>[/<foo>-<bar>]', 'Resources:Users', [
			'parameters' => [
				'id' => ['requirement' => '\d+']
			],
			'priority' => 1
		]);

		$router[] = new Route('<presenter>/<action>', 'Homepage:default');

		return $router;
	}

}

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.

Tento web používá k poskytování služeb a analýze návštěvnosti soubory cookie. Používáním tohoto webu s tím souhlasíte. V pořádku Další informace