From 2680c4538cd6cf86fcbc015e2b4eaac3033b6289 Mon Sep 17 00:00:00 2001 From: Sven Slootweg Date: Sun, 7 Apr 2013 01:09:05 +0200 Subject: [PATCH] Add support for restricting routes to specific methods --- components/component.router.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/components/component.router.php b/components/component.router.php index bf9ebd4..73f28d4 100644 --- a/components/component.router.php +++ b/components/component.router.php @@ -88,6 +88,16 @@ class CPHPRouter extends CPHPBaseClass throw new InvalidArgumentException("Target is missing from CPHPRoute options element."); } + if(!empty($route_destination['methods'])) + { + $sMethods = (!is_array($route_destination['methods'])) ? array($route_destination['methods']) : $route_destination['methods']; + + if(!in_array(strtolower($_SERVER['REQUEST_METHOD']), $sMethods)) + { + continue; + } + } + if(!isset($route_destination['authenticator'])) { $authenticated = true;