forked from islamic-network/api.alquran.cloud
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquran.php
27 lines (21 loc) · 990 Bytes
/
quran.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
use Quran\Helper\Log;
use Quran\Helper\Request as ApiRequest;
$app->group('/v1', function() {
// Without edition
$this->get('/quran', function (Request $request, Response $response) {
$edition = 'quran-simple';
$quran = new Quran\Api\CompleteResponse($edition);
// $this->logger->addInfo('edition ::: ' . time() . ' ::', Log::format($_SERVER, $_REQUEST));
return $response->withJson($quran->get(), $quran->getCode());
});
// With edition
$this->get('/quran/{edition}', function (Request $request, Response $response) {
$edition = $request->getAttribute('edition');
$quran = new Quran\Api\CompleteResponse($edition);
// $this->logger->addInfo('edition ::: ' . time() . ' ::', Log::format($_SERVER, $_REQUEST));
return $response->withJson($quran->get(), $quran->getCode());
});
});