Skip to content

Instantly share code, notes, and snippets.

@dusterio
Created November 14, 2016 04:01
Show Gist options
  • Save dusterio/e1cfd35b34d9b9fcb93125f6797cad0e to your computer and use it in GitHub Desktop.
Save dusterio/e1cfd35b34d9b9fcb93125f6797cad0e to your computer and use it in GitHub Desktop.
<?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