-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrouter.php
More file actions
executable file
·23 lines (22 loc) · 934 Bytes
/
router.php
File metadata and controls
executable file
·23 lines (22 loc) · 934 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
<?php
/**
* Determine the function source file to load.
*/
$documentRoot = __DIR__.'/../../../';
if ($functionSource = $_SERVER['FUNCTION_SOURCE'] ?? null) {
if (0 !== strpos($functionSource, '/')) {
// Make the path relative
$relativeSource = $documentRoot.$functionSource;
if (!file_exists($relativeSource)) {
throw new RuntimeException(sprintf('Unable to load function from "%s"', $relativeSource));
}
require_once $_SERVER['SCRIPT_FILENAME'] = $relativeSource;
} else {
require_once $_SERVER['SCRIPT_FILENAME'] = $functionSource;
}
} elseif (file_exists($defaultSource = $documentRoot.'index.php')) {
// Default to "index.php" in the root of the application.
require_once $_SERVER['SCRIPT_FILENAME'] = $defaultSource;
} else {
throw new RuntimeException('Did not find your index.php. Please define environment variable "FUNCTION_SOURCE".');
}