Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom matching routes #6

Open
hurvajs77 opened this issue Dec 1, 2016 · 0 comments
Open

Custom matching routes #6

hurvajs77 opened this issue Dec 1, 2016 · 0 comments

Comments

@hurvajs77
Copy link

When I define custom matching routes and specify HTTP method for them, so that I'm able to access to specified route with any HTTP method.

Example of router definitions:

$apiRouter[] = new Routers\Route(
	'api/message[/<action>]',
	'Messages:Webhook:default',
	[
		'methods' => [
			Nette\Http\Request::POST => 'click',
			Nette\Http\Request::POST => 'deliver'
		]
	]);

And presenter:

class WebhookPresenter extends UI\Presenter
{
	public function actionClick()
	{
		$this->sendJson([
			'presenter' => 'Api:Message:Message',
			'action' => 'click',
			'timestamp' => time()
		]);
	}

	public function actionDeliver()
	{
		$this->sendJson([
			'presenter' => 'Api:Message:Message',
			'action' => 'deliver',
			'timestamp' => time()
		]);
	}
}

If I try to call URL via cURL with POST, I'll get correct response: {"presenter":"Api:Message:Message","action":"deliver","timestamp":1480584275}

But, if I call it with GET method, I'll get same response. FORBIDDEN or BAD_REQUEST is expected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant