Skip to content

Commit

Permalink
fix API to support apache headers
Browse files Browse the repository at this point in the history
  • Loading branch information
brookgagnon committed Sep 18, 2024
1 parent e38330e commit 76f0692
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.3.3-20240913
5.3.3-20240918
12 changes: 12 additions & 0 deletions api.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ class OBFAPI

public function __construct()
{
// merge in our apache headers with $_SERVER (if not already set)
if (function_exists('apache_request_headers')) {
$headers = apache_request_headers();
foreach ($headers as $header => $value) {
$value = trim($value);
$index = 'HTTP_' . strtoupper(str_replace('-', '_', trim($header)));
if (!isset($_SERVER[$index])) {
$_SERVER[$index] = $value;
}
}
}

if (str_starts_with($_SERVER['REQUEST_URI'], '/api/v2/')) {
// we have routes for this request method? find the regex pattern to match with, and variables to extract.
$routes = json_decode(file_get_contents('routes.json'));
Expand Down

0 comments on commit 76f0692

Please sign in to comment.