From 78c5ea9ca6f2f52a10b8270fb71af7e21763205e Mon Sep 17 00:00:00 2001 From: zhaiyuxin103 Date: Sat, 6 Apr 2024 10:47:26 +0800 Subject: [PATCH] feat(middleware): accept header (#20) --- app/Http/Middleware/AcceptHeader.php | 22 ++++++++++++++++++++++ bootstrap/app.php | 4 +++- 2 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 app/Http/Middleware/AcceptHeader.php diff --git a/app/Http/Middleware/AcceptHeader.php b/app/Http/Middleware/AcceptHeader.php new file mode 100644 index 0000000..9dd1b73 --- /dev/null +++ b/app/Http/Middleware/AcceptHeader.php @@ -0,0 +1,22 @@ +headers->set('Accept', 'application/json'); + + return $next($request); + } +} diff --git a/bootstrap/app.php b/bootstrap/app.php index d654276..d115ad4 100644 --- a/bootstrap/app.php +++ b/bootstrap/app.php @@ -12,7 +12,9 @@ health: '/up', ) ->withMiddleware(function (Middleware $middleware) { - // + $middleware->api(prepend: [ + \App\Http\Middleware\AcceptHeader::class, + ]); }) ->withExceptions(function (Exceptions $exceptions) { //