diff --git a/api/api.php b/api/api.php index 6799e7cdee..31fe0b1075 100644 --- a/api/api.php +++ b/api/api.php @@ -252,6 +252,11 @@ $params = $_GET; $requestPayload = json_decode($app->request()->getBody(), true); +$endpoints = Bootstrap::getCustomEndpoints(); +foreach($endpoints as $endpoint) { + require $endpoint; +} + /** * Extension Alias */ diff --git a/api/core/Directus/Bootstrap.php b/api/core/Directus/Bootstrap.php index 9e0355513e..e74b72da02 100644 --- a/api/core/Directus/Bootstrap.php +++ b/api/core/Directus/Bootstrap.php @@ -57,6 +57,24 @@ public static function extensionExists($extensionName) { return array_key_exists($extensionName, $extensions); } + /** + * Get all custom endpoints + * @return array - list of endpoint files loaded + * @throws \Exception + */ + public static function getCustomEndpoints() + { + self::requireConstants('APPLICATION_PATH', __FUNCTION__); + + $customEndpointsPath = APPLICATION_PATH . '/customs/endpoints/*.php'; + $paths = []; + foreach (glob($customEndpointsPath) as $filename) { + $paths[] = $filename; + } + + return $paths; + } + /** * Used to interrupt the bootstrapping of a singleton if the constants it * requires aren't defined. diff --git a/customs/.htaccess b/customs/.htaccess index ef17dd6ae2..8fb79e3fa8 100644 --- a/customs/.htaccess +++ b/customs/.htaccess @@ -1,2 +1,4 @@ # Prevent directory listing IndexIgnore * + +deny from all diff --git a/customs/endpoints/.gitkeep b/customs/endpoints/.gitkeep new file mode 100644 index 0000000000..e69de29bb2