Skip to content

Commit

Permalink
Move headers out of getJson functions
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonXLF committed Sep 20, 2023
1 parent 236410c commit 85a59e0
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 9 deletions.
3 changes: 3 additions & 0 deletions api/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
require '../vendor/autoload.php';

if ($_SERVER['QUERY_STRING']) {
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
echo (new LinkCount(get('page'), get('project'), get('namespaces')))->getJson();

exit;
}

Expand Down
5 changes: 0 additions & 5 deletions includes/LinkCount.php
Original file line number Diff line number Diff line change
Expand Up @@ -233,11 +233,6 @@ public function getHtml() {
}

public function getJson() {
if (!headers_sent()) {
header('Content-Type: application/json');
header('Access-Control-Allow-Origin: *');
}

if (isset($this->error)) {
return json_encode(['error' => $this->error]);
}
Expand Down
4 changes: 0 additions & 4 deletions includes/ProjectPrefixSearch.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@ public function __construct($prefix) {
}

public function getJson() {
if (!headers_sent()) {
header('Content-Type: application/json');
}

return json_encode([
'projects' => $this->projects,
'exact' => $this->exact
Expand Down
1 change: 1 addition & 0 deletions projects/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@

require '../vendor/autoload.php';

header('Content-Type: application/json');
echo (new ProjectPrefixSearch(get('prefix')))->getJson();

0 comments on commit 85a59e0

Please sign in to comment.