Skip to content

Commit 255da4d

Browse files
author
Stefano Azzolini
committed
Merge branch 'release/api_groups'
2 parents 559e7b0 + 143bd85 commit 255da4d

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

classes/API.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,20 @@ public static function error($message,$status=501){
1717
}
1818

1919
public static function run(callable $main = null){
20+
$API_VERS = Options::get('base.api_version','');
2021
// Load Routes
2122
$route_file = ltrim(Options::get('base.endpoints',APP_DIR.'/routes.php'),'/');
2223
// Single file
2324
if (is_file($route_file)){
2425
include $route_file;
2526
} else {
2627
// Load directory
27-
$route_file .= rtrim('/'.Options::get('base.api_version',''),'/');
28-
if (is_dir($route_file))
29-
array_map(function($f){include($f);},glob($route_file.'/*.php'));
28+
$route_file .= rtrim('/'.$API_VERS,'/');
29+
if (is_dir($route_file)){
30+
Route::group("/$API_VERS",function(){
31+
array_map(function($f){include($f);},glob($route_file.'/*.php'));
32+
});
33+
}
3034
}
3135
Event::trigger('api.run',[Options::get('base.api_version','')]);
3236
if ($main) $main();

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "API extensions for Caffeina Core",
55
"keywords": ["core","api","rest","server"],
66
"homepage": "http://labs.caffeina.co/tech/core",
7-
"version": "1.0.0",
7+
"version": "1.0.1",
88
"license": "MIT",
99
"authors": [
1010
{

0 commit comments

Comments
 (0)