Skip to content

Conversation

nickygerritsen
Copy link
Member

Fixes #2685.

@nickygerritsen nickygerritsen added this pull request to the merge queue Nov 23, 2024
Merged via the queue into DOMjudge:main with commit 38179a0 Nov 23, 2024
32 checks passed
@nickygerritsen nickygerritsen deleted the api-respond-in-json branch November 23, 2024 13:31
$acceptHeader = $request->headers->get('accept');

if (!$acceptHeader
|| str_starts_with($acceptHeader, 'text/html')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this allowed by the specs? I think if someone explicit requests text/html only we should still return text/html.
Can we do the alternative of when the acceptHeader contains app/json or is */* set it to app/json only?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To me it's annoying if you open a wrong api in your browser you don't get json.
Seeks an n=1 test with GitHub also returns json: https://api.github.com/bla

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Give API error responses in JSON format

3 participants