Skip to content

Use status code constants via React\Http\Message\Response class #76

Answered by clue
shuvroroy asked this question in Q&A
Discussion options

You must be logged in to vote

#114 has just been merged, so the following examples are now supported out of the box! 🎉

$app->get('/user', function () {
    return React\Http\Message\Response::plaintext(
        "Hello wörld!\n"
    );
});

$app->get('/users', function () {
    return React\Http\Message\Response::plaintext(
        "Not found.\n"
    )->withStatus(React\Http\Message\Response::STATUS_NOT_FOUND);
});

All status codes are now available as status constants like React\Http\Message\Response::STATUS_OK or React\Http\Message\Response::STATUS_NOT_FOUND etc.

See also updated docs: https://framework-x.org/docs/api/response/#status-codes

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by clue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants