class RequestUtil
Constants
| INTERNAL_ATTRIBUTE |
Attribute key marking a request as an internal API call (dispatched via {\Flarum\Api\Client}, e.g. when a frontend page preloads its API document) rather than a request from an external client. |
Methods
Determine if the request is an API request. We do not manually set the `Accepts` header for API requests, so we need to check the priority list to determine whether it is or not.
Whether this request was dispatched internally. Internal requests are not held to the JSON:API spec's strict query-parameter validation: a frontend page forwards the browser's query string (which may carry tracking params like `fbclid`) into the API client, and those must not 400 the page.
Determine the client's preferred content type out of the given list.
No description
No description
No description
Details
at
line 24
static bool
isApiRequest(ServerRequestInterface $request)
Determine if the request is an API request. We do not manually set the `Accepts` header for API requests, so we need to check the priority list to determine whether it is or not.
Normal browsing requests will have `text/html` as their preferred content type, while API will have `* / *`.
at
line 34
static bool
isHtmlRequest(ServerRequestInterface $request)
at
line 46
static ServerRequestInterface
withInternal(ServerRequestInterface $request)
at
line 57
static bool
isInternal(ServerRequestInterface $request)
Whether this request was dispatched internally. Internal requests are not held to the JSON:API spec's strict query-parameter validation: a frontend page forwards the browser's query string (which may carry tracking params like `fbclid`) into the API client, and those must not 400 the page.
at
line 69
static string
getPreferredContentType(ServerRequestInterface $request, array $types)
Determine the client's preferred content type out of the given list.