Skip to content

Commit

Permalink
Add customs endpoints without the needs to create extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
wellingguzman committed Jul 15, 2016
1 parent 682a7a1 commit 289f2c3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
5 changes: 5 additions & 0 deletions api/api.php
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,11 @@
$params = $_GET;
$requestPayload = json_decode($app->request()->getBody(), true);

$endpoints = Bootstrap::getCustomEndpoints();
foreach($endpoints as $endpoint) {
require $endpoint;
}

/**
* Extension Alias
*/
Expand Down
18 changes: 18 additions & 0 deletions api/core/Directus/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions customs/.htaccess
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
# Prevent directory listing
IndexIgnore *

deny from all
Empty file added customs/endpoints/.gitkeep
Empty file.

0 comments on commit 289f2c3

Please sign in to comment.