mirror of
https://github.com/flextype/flextype.git
synced 2025-08-23 05:16:03 +02:00
feat(core): create api routes #159
This commit is contained in:
@@ -126,9 +126,10 @@ include_once 'dependencies.php';
|
||||
include_once 'middlewares.php';
|
||||
|
||||
/**
|
||||
* Include Routes (web)
|
||||
* Include Routes (web, api)
|
||||
*/
|
||||
include_once 'routes/web.php';
|
||||
include_once 'routes/api.php';
|
||||
|
||||
|
||||
/**
|
||||
|
30
flextype/routes/api.php
Normal file
30
flextype/routes/api.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/**
|
||||
* Flextype (http://flextype.org)
|
||||
* Founded by Sergey Romanenko and maintained by Flextype Community.
|
||||
*/
|
||||
|
||||
namespace Flextype;
|
||||
|
||||
use Psr\Http\Message\ResponseInterface as Response;
|
||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||
|
||||
$app->get('/api/entries', function (Request $request, Response $response, array $args) use ($flextype) {
|
||||
|
||||
// Get Query Params
|
||||
$query = $request->getQueryParams();
|
||||
|
||||
//
|
||||
if (!isset($query['auth_token'])) {
|
||||
return $response->withJson(["detail" => "Incorrect authentication credentials."]);
|
||||
}
|
||||
|
||||
// Response data
|
||||
$data = [];
|
||||
|
||||
// Return response
|
||||
return $response->withJson($data);
|
||||
});
|
Reference in New Issue
Block a user