mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-19 09:41:25 +00:00
Compare commits
4 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3d45851d9b | |||
| db78135d19 | |||
| c4fcf750d4 | |||
| ee5c2207f8 |
@@ -44,6 +44,9 @@ class Request {
|
||||
}
|
||||
|
||||
public function getIsSecure() {
|
||||
if(isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && strtolower($_SERVER['HTTP_X_FORWARDED_PROTO']) === 'https') {
|
||||
return true;
|
||||
}
|
||||
return isset($_SERVER['HTTPS']) ? true : (isset($_SERVER['SERVER_PORT']) && $_SERVER['SERVER_PORT'] === 443);
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ class Response {
|
||||
if($httpCode !== null) {
|
||||
$this->httpCode($httpCode);
|
||||
}
|
||||
|
||||
|
||||
$this->header('Location: ' . $url);
|
||||
die();
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ class RouterBase {
|
||||
|
||||
$this->currentRoute = $route;
|
||||
|
||||
if($route instanceof RouterGroup && is_callable($route->getCallback())) {
|
||||
if($route instanceof RouterGroup && $route->matchRoute($this->request) && is_callable($route->getCallback())) {
|
||||
$group = $route;
|
||||
$route->renderRoute($this->request);
|
||||
$mergedSettings = array_merge($route->getMergeableSettings(), $settings);
|
||||
@@ -126,12 +126,6 @@ class RouterBase {
|
||||
|
||||
$route = $this->controllerUrlMap[$i];
|
||||
|
||||
if($route->getGroup() !== null) {
|
||||
if($route->getGroup()->matchDomain($this->request) === false) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
$routeMatch = $route->matchRoute($this->request);
|
||||
|
||||
if($routeMatch) {
|
||||
|
||||
@@ -66,7 +66,12 @@ class RouterGroup extends RouterEntry {
|
||||
}
|
||||
|
||||
public function matchRoute(Request $request) {
|
||||
return null;
|
||||
// Skip if prefix doesn't match
|
||||
if($this->getPrefix() !== null && stripos($request->getUri(), $this->getPrefix()) === false) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->matchDomain($request);
|
||||
}
|
||||
|
||||
public function setExceptionHandler($class) {
|
||||
|
||||
Reference in New Issue
Block a user