update handler
This commit is contained in:
parent
9d95843af6
commit
37d7a4d630
|
|
@ -1,5 +1,13 @@
|
||||||
FROM docker.io/bitnami/laravel:10
|
FROM docker.io/bitnami/laravel:10
|
||||||
|
|
||||||
|
RUN apt update
|
||||||
|
RUN apt install -y entr
|
||||||
|
|
||||||
|
# php.ini
|
||||||
|
COPY php.ini /opt/bitnami/php/lib/php.ini
|
||||||
|
|
||||||
|
# Run
|
||||||
|
EXPOSE 8000
|
||||||
COPY ./docker-entrypoint.sh /docker-entrypoint.sh
|
COPY ./docker-entrypoint.sh /docker-entrypoint.sh
|
||||||
RUN chmod +x /docker-entrypoint.sh
|
RUN chmod +x /docker-entrypoint.sh
|
||||||
ENTRYPOINT /docker-entrypoint.sh
|
ENTRYPOINT /docker-entrypoint.sh
|
||||||
|
|
|
||||||
|
|
@ -14,9 +14,8 @@ class UserController extends Controller
|
||||||
{
|
{
|
||||||
$this->middleware('auth');
|
$this->middleware('auth');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function users()
|
public function users()
|
||||||
{
|
{
|
||||||
return User::all();
|
return response()->json(User::all());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,10 @@
|
||||||
|
|
||||||
namespace App\Exceptions;
|
namespace App\Exceptions;
|
||||||
|
|
||||||
use Exception;
|
use Dotenv\Exception\ValidationException;
|
||||||
|
use Illuminate\Auth\AuthenticationException;
|
||||||
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
|
||||||
use Illuminate\Http\JsonResponse;
|
use Illuminate\Http\Exceptions\HttpResponseException;
|
||||||
use Illuminate\Http\Response;
|
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
|
||||||
class Handler extends ExceptionHandler
|
class Handler extends ExceptionHandler
|
||||||
|
|
@ -42,21 +42,11 @@ class Handler extends ExceptionHandler
|
||||||
*/
|
*/
|
||||||
public function render($request, Throwable $exception)
|
public function render($request, Throwable $exception)
|
||||||
{
|
{
|
||||||
if ($request->expectsJson()) {
|
return match (true) {
|
||||||
}
|
$exception instanceof HttpResponseException => $exception->getResponse(),
|
||||||
|
$exception instanceof AuthenticationException => $this->unauthenticated($request, $exception),
|
||||||
return $this->prepareJsonResponse($request, $exception);
|
$exception instanceof ValidationException => $this->convertValidationExceptionToResponse($exception, $request),
|
||||||
return parent::render($request, $exception);
|
default => $this->prepareJsonResponse($request, $exception),
|
||||||
}
|
};
|
||||||
|
|
||||||
protected function prepareJsonResponse($request, Throwable $exception)
|
|
||||||
{
|
|
||||||
return new JsonResponse(
|
|
||||||
[
|
|
||||||
'message' => $exception->getMessage(),
|
|
||||||
'code' => $exception->getCode(),
|
|
||||||
],
|
|
||||||
$this->isHttpException($exception) ? $exception->getStatusCode() : Response::HTTP_INTERNAL_SERVER_ERROR
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -8,4 +8,10 @@ else
|
||||||
composer u
|
composer u
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [ ! -f "$PWD/.env" ]; then
|
||||||
|
cp .env.example .env
|
||||||
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
# find . -name '*.php' | entr watch file
|
||||||
php artisan serve --host "0.0.0.0"
|
php artisan serve --host "0.0.0.0"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue