Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose all status code constants via Response class #432

Merged
merged 2 commits into from
Nov 7, 2021

Conversation

clue
Copy link
Member

@clue clue commented Nov 7, 2021

With this changeset, we now expose all status code constants via Response class. This is done by implementing the PSR-7 Message Util StatusCodeInterface which means that most common HTTP status codes are now available as class constants with the STATUS_* prefix. For instance, the 200 OK and 404 Not Found status codes can used as Response::STATUS_OK and Response::STATUS_NOT_FOUND respectively.

Using status code constants is entirely optional and using status codes as integers remains supported of course, but we now use these constants throughout our documentation and examples to make them more readable. Accordingly, this does not affect backwards compatibility.

This builds on top of #406 (thank you @WyriHaximus!), but instead of exposing a new interface, this changeset simply ensures the existing Response class implements this very interface. This makes it much easier to use these constants in application code because no separate import is required.

Supersedes / closes #406

@clue clue added this to the v1.6.0 milestone Nov 7, 2021
@clue clue requested a review from WyriHaximus November 7, 2021 10:09
Introducing using these constants makes it easier to identify a
specific HTTP status used in our code. And for our users to use
readable status codes in their own code.
@clue
Copy link
Member Author

clue commented Nov 7, 2021

Rebased on master to resolve merge conflict now that #431 is in :shipit:

This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants