Initial moves to new API scheme.

Implements a better middleware for handling API authentication, as well
as cleaner route handling.
This commit is contained in:
Dane Everitt 2017-04-02 00:11:52 -04:00
parent 55bf26e518
commit 87530cdc01
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
20 changed files with 706 additions and 572 deletions

View file

@ -46,10 +46,19 @@ class Handler extends ExceptionHandler
*/
public function render($request, Exception $exception)
{
if ($request->expectsJson()) {
if ($request->expectsJson() || $request->isJson() || $request->is('api/*', 'remote/*', 'daemon/*')) {
if (config('app.debug')) {
$report = [
'code' => (! $this->isHttpException($exception)) ?: $exception->getStatusCode(),
'message' => class_basename($exception) . ' in ' . $exception->getFile() . ' on line ' . $exception->getLine(),
];
}
$response = response()->json([
'error' => ($exception instanceof DisplayException) ? $exception->getMessage() : 'An unhandled error occured while attempting to process this request.',
], ($this->isHttpException($exception)) ? $exception->getStatusCode() : 500);
'error' => $exception->getMessage(),
'exception' => ! isset($report) ?: $report,
], ($this->isHttpException($exception)) ? $exception->getStatusCode() : 500, [], JSON_UNESCAPED_SLASHES);
parent::report($exception);
}