ro
c29513945b
There were some outstanding changes made a few months ago that haven't been checked in, so getting those as the final commit before the transition to Laravel
49 lines
1.5 KiB
PHP
49 lines
1.5 KiB
PHP
<?php
|
|
|
|
namespace brain\controller;
|
|
|
|
use Psr\Http\Message\ResponseInterface;
|
|
use Psr\Http\Message\ServerRequestInterface;
|
|
|
|
class RouteControl
|
|
{
|
|
// TODO: Add additional HTTP Methods to better organize API control paths
|
|
public function get(
|
|
ServerRequestInterface $request,
|
|
ResponseInterface $response,
|
|
array $args
|
|
): ResponseInterface {
|
|
switch (isset($args['first']) ? $args['first'] : 'index') {
|
|
case 'dashboard':
|
|
return DashControl::start($request, $response, $args);
|
|
break;
|
|
case 'api':
|
|
return APIControl::get($request, $response, $args);
|
|
break;
|
|
default:
|
|
return IndexControl::start($request, $response, $args);
|
|
break;
|
|
}
|
|
}
|
|
|
|
public function post(
|
|
ServerRequestInterface $request,
|
|
ResponseInterface $response,
|
|
array $args
|
|
): ResponseInterface {
|
|
switch (isset($args['first']) ? $args['first'] : 'index') {
|
|
case 'api':
|
|
return APIControl::post($request, $response, $args);
|
|
break;
|
|
default:
|
|
$result = [
|
|
'message' => "Nothing matches this route. That's unfortunate",
|
|
'type' => 'TASK_NONE',
|
|
];
|
|
$response->getBody()->write(json_encode($result));
|
|
|
|
return $response->withHeader('Content-Type', 'application/json');
|
|
}
|
|
}
|
|
}
|