Skip to content

Instantly share code, notes, and snippets.

@dusterio
Created Nov 14, 2016
Embed
What would you like to do?
<?php
return (static function() {
$configTemplate = [
'routes' => [
[
'aggregate' => true,
'method' => 'GET',
'path' => '/v1/devices/{mac}/details',
'actions' => [
'device' => [
'service' => 'core',
'method' => 'GET',
'path' => 'devices/{mac}',
'sequence' => 0,
'critical' => true
],
'ping' => [
'service' => 'history',
'output_key' => false,
'method' => 'POST',
'path' => '/{mac}/ping',
'sequence' => 0,
'critical' => false
],
'settings' => [
'service' => 'core',
'output_key' => 'network.settings',
'method' => 'GET',
'path' => 'networks/{device%network_id}',
'sequence' => 1,
'critical' => false
]
]
]
],
];
$sections = ['services', 'routes', 'global'];
foreach ($sections as $section) {
$config = env('GATEWAY_' . strtoupper($section), false);
${$section} = $config ? json_decode($config, true) : $configTemplate[$section];
}
return compact($sections);
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment