New code for API 2

This commit is contained in:
Sander Dorigo
2022-06-23 09:33:43 +02:00
parent e0c9d3627e
commit b12d72bef6
13 changed files with 108 additions and 11 deletions

View File

@@ -27,6 +27,7 @@ use Illuminate\Support\ServiceProvider;
use Laravel\Passport\Passport;
use Laravel\Sanctum\Sanctum;
use URL;
use Illuminate\Support\Facades\Response;
/**
* @codeCoverageIgnore
@@ -45,6 +46,20 @@ class AppServiceProvider extends ServiceProvider
if ('heroku' === config('app.env')) {
URL::forceScheme('https');
}
Response::macro('api', function ($value) {
$headers = [
'Cache-Control' => 'no-store'
];
$uuid = (string) request()->header('X-Trace-Id');
if ('' !== trim($uuid) && (preg_match('/^[a-f\d]{8}(-[a-f\d]{4}){4}[a-f\d]{8}$/i', trim($uuid)) === 1)) {
$headers['X-Trace-Id'] = $uuid;
}
return response()
->json($value)
->withHeaders($headers);
});
}
/**