Skip to content

Commit

Permalink
Merge pull request #74 from JarvusInnovations/develop
Browse files Browse the repository at this point in the history
Release: gatekeeper v2.2.2
  • Loading branch information
themightychris authored Oct 5, 2019
2 parents e62a686 + f4206b3 commit 3723645
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 30 deletions.
9 changes: 0 additions & 9 deletions .github/workflows/holo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,3 @@ jobs:
ref: releases/v2
holobranch: emergence-skeleton
commit-to: emergence/skeleton/v2
- name: 'Update holobranch: emergence/vfs-site/v2'
uses: JarvusInnovations/hologit@actions/projector/v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HAB_LICENSE: accept
with:
ref: releases/v2
holobranch: emergence-vfs-site
commit-to: emergence/vfs-site/v2
19 changes: 12 additions & 7 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
// See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp

// List of extensions which should be recommended for users of this workspace.
"recommendations": [
"bmewburn.vscode-intelephense-client",
"imperez.smarty"
]
// List of extensions which should be recommended for users of this workspace.
"recommendations": [
"bmewburn.vscode-intelephense-client",
"imperez.smarty",
"felixfbecker.php-debug",
"mtxr.sqltools"
],
"unwantedRecommendations": [
"ms-mssql.mssql"
]
}
22 changes: 22 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Listen for XDebug",
"type": "php",
"request": "launch",
"port": 7089,
"pathMappings": {
"/hab/svc/php-runtime/var/site/php-classes/Emergence": "${workspaceFolder:emergence-skeleton-v1}/php-classes/Emergence",
"/hab/svc/php-runtime/var/site": "${workspaceFolder:gatekeeper}",
"/src/emergence-php-core": "${workspaceFolder:emergence-php-core}"
},
"ignore": [
"**/vendor/**/*"
]
}
]
}
2 changes: 1 addition & 1 deletion html-templates/endpoints/endpointEdit.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<h4>Routing</h4>

{capture assign=pathInputHtml}{strip}
http://{tif Gatekeeper\Gatekeeper::$apiHostname ? Gatekeeper\Gatekeeper::$apiHostname : "$.server.HTTP_HOST/api"}/&thinsp;
{Gatekeeper\Gatekeeper::getApiBaseUrl()}/&thinsp;
<input type="text" size=20 name="Path" required value="{refill field=Path default=$Endpoint->Path}" placeholder="transitview/v1">
{/strip}{/capture}
{labeledField html=$pathInputHtml type=compound label='Public Path' error=$errors.Path required=true}
Expand Down
8 changes: 1 addition & 7 deletions php-classes/Gatekeeper/Endpoints/Endpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -375,13 +375,7 @@ public function applyRewrites($url)

public function getExternalUrl()
{
$url = 'http://';

if (Gatekeeper::$apiHostname) {
$url .= Gatekeeper::$apiHostname;
} else {
$url .= Site::getConfig('primary_hostname') . '/api';
}
$url = Gatekeeper::getApiBaseUrl();

$url .= '/' . $this->Path;

Expand Down
16 changes: 12 additions & 4 deletions php-classes/Gatekeeper/Endpoints/Pinger.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Gatekeeper\Endpoints;

use Site;
use Cache;
use HttpProxy;

Expand All @@ -21,7 +22,7 @@ public static function pingOverdueEndpoints($verbose = false)

if (
$lastPing === false
|| $Endpoint->PingFrequency < time()-$lastPing['time'] // * 60
|| $Endpoint->PingFrequency*60 < time()-$lastPing['time']
) {
static::pingEndpoint($Endpoint, $verbose);
}
Expand All @@ -38,11 +39,18 @@ public static function pingEndpoint(Endpoint $Endpoint, $verbose = false)
$response = HttpProxy::relayRequest([
'autoAppend' => false,
'autoQuery' => false,
'method' => 'GET',
'url' => rtrim($Endpoint->InternalEndpoint, '/') . '/' . ltrim($Endpoint->PingURI, '/'),
'interface' => ApiRequestHandler::$sourceInterface,
'timeout' => 15,
'timeoutConnect' => 5,
'returnResponse' => true
'returnResponse' => true,
'forwardHeaders' => [],
'headers' => [
'Accept: */*',
'Accept-Language: *',
'User-Agent: ' . (ApiRequestHandler::$poweredByHeader ?: Site::$title)
]
]);


Expand Down Expand Up @@ -107,8 +115,8 @@ public static function pingEndpoint(Endpoint $Endpoint, $verbose = false)
Cache::store("endpoints/{$Endpoint->ID}/last-ping", [
'time' => time(),
'testPassed' => $testPassed
], ($Endpoint->PingFrequency+5)); // * 60
], ($Endpoint->PingFrequency+5)*60);

return $testPassed;
}
}
}
18 changes: 18 additions & 0 deletions php-classes/Gatekeeper/Gatekeeper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Gatekeeper;

use Site;
use JSON;

class Gatekeeper
Expand All @@ -10,6 +11,23 @@ class Gatekeeper
public static $portalHostname;
public static $authRealm = 'Gatekeeper';

public static function getApiBaseUrl()
{
$url = Site::getConfig('ssl') ? 'https://' : 'http://';

if (static::$apiHostname) {
$url .= is_array(static::$apiHostname) ? static::$apiHostname[0] : static::$apiHostname;
} elseif (!empty($_SERVER['HTTP_HOST'])) {
$url .= $_SERVER['HTTP_HOST'];
$url .= '/api';
} else {
$url .= Site::getConfig('primary_hostname') ?: 'localhost';
$url .= '/api';
}

return $url;
}

public static function authorizeTestApiAccess()
{
if (
Expand Down
10 changes: 8 additions & 2 deletions site-root/health/endpoint-tests.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@
'interface' => ApiRequestHandler::$sourceInterface,
'timeout' => 15,
'timeoutConnect' => 5,
'returnResponse' => true
'returnResponse' => true,
'forwardHeaders' => [],
'headers' => [
'Accept: */*',
'Accept-Language: *',
'User-Agent: ' . (ApiRequestHandler::$poweredByHeader ?: Site::$title)
]
]);

// evaluate success
Expand All @@ -77,7 +83,7 @@
<td><?=$Endpoint->Path?></td>
<td><?=$Endpoint->PingURI?></td>
<td><?=$Endpoint->PingTestPattern?></td>
<td><?=($url || '')?></td>
<td><?=($url ?: '')?></td>
<td><?=($response ? $response['info']['http_code'] : '')?></td>
<td><?=($response ? (strlen($response['body']) . ' bytes') : '')?></td>
<td><?=($testPassed === null ? '' : ($testPassed ? 'Y' : 'N'))?></td>
Expand Down

0 comments on commit 3723645

Please sign in to comment.