Skip to content

Commit f8e3756

Browse files
committed
Add the map config to the controller
1 parent a991566 commit f8e3756

2 files changed

Lines changed: 18 additions & 11 deletions

File tree

app/Http/Controllers/Backend/MediawikiHostMapController.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,27 @@ class MediawikiHostMapController extends Controller {
1010
public function getWikiVersionToHostMapForDomain(Request $request): \Illuminate\Http\JsonResponse
1111
{
1212
$domain = $request->query('domain');
13-
$version = Wiki::where('domain', $domain)
13+
$wikiDbVersion = Wiki::where('domain', $domain)
1414
->whereNull('deleted_at')
1515
->leftJoin('wiki_dbs', 'wiki_id', '=', 'wikis.id')
1616
->pluck('version')
1717
->first();
1818

19-
if (is_null($version)) {
19+
if (is_null($wikiDbVersion)) {
2020
abort(401);
2121
}
22-
$mapPath = "";
23-
if (!file_exists($mapPath)) {
24-
throw new \Exception("MW host mapping file not found at {$mapPath}");
25-
}
26-
$host = "something from $mapPath";
22+
$mwDbToHostMap = [
23+
'mw1.39-wbs1' => '139-app',
24+
'mw1.43-wbs1' => '143-app'
25+
];
2726

2827
return response()
2928
->json([
3029
'domain' => $domain,
31-
'version' => $version,
32-
'host' => $host
30+
'version' => $wikiDbVersion,
31+
'host' => $mwDbToHostMap[$wikiDbVersion],
3332
])
34-
->header('x-host', $host)
35-
->header('x-version', $version);
33+
->header('x-host', $mwDbToHostMap[$wikiDbVersion])
34+
->header('x-version', $wikiDbVersion);
3635
}
3736
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<?php
2+
3+
namespace Routes\Ingress;
4+
5+
class getWikiVersionToHostMapForDomain
6+
{
7+
8+
}

0 commit comments

Comments
 (0)