mirror of
https://github.com/firefly-iii/firefly-iii.git
synced 2025-09-02 19:16:39 +00:00
Return correct headers
This commit is contained in:
@@ -26,6 +26,7 @@ namespace FireflyIII\Api\V1\Controllers;
|
||||
|
||||
use Carbon\Carbon;
|
||||
use Carbon\Exceptions\InvalidFormatException;
|
||||
use FireflyIII\Exceptions\BadHttpHeaderException;
|
||||
use FireflyIII\Models\Preference;
|
||||
use FireflyIII\Models\TransactionCurrency;
|
||||
use FireflyIII\Support\Facades\Amount;
|
||||
@@ -60,11 +61,13 @@ abstract class Controller extends BaseController
|
||||
use ValidatesRequests;
|
||||
|
||||
protected const string CONTENT_TYPE = 'application/vnd.api+json';
|
||||
protected const string JSON_CONTENT_TYPE = 'application/json';
|
||||
|
||||
/** @var array<int, string> */
|
||||
protected array $allowedSort;
|
||||
protected ParameterBag $parameters;
|
||||
protected bool $convertToNative = false;
|
||||
protected array $accepts = ['application/json'];
|
||||
protected TransactionCurrency $nativeCurrency;
|
||||
|
||||
/**
|
||||
@@ -82,9 +85,15 @@ abstract class Controller extends BaseController
|
||||
$this->convertToNative = Amount::convertToNative();
|
||||
$this->nativeCurrency = Amount::getNativeCurrency();
|
||||
app()->setLocale($language);
|
||||
|
||||
}
|
||||
|
||||
|
||||
// filter down what this endpoint accepts.
|
||||
if (!$request->accepts($this->accepts)) {
|
||||
throw new BadHttpHeaderException(sprintf('Sorry, Accept header "%s" is not something this endpoint can provide.', $request->header('Accept')));
|
||||
}
|
||||
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
);
|
||||
|
Reference in New Issue
Block a user