Correct way to redirect. #106
-
Hi, In order to do that i used this way, because RedirectHandler doesn't work what i expected. This is a part of my //// ....
public function __invoke(ServerRequestInterface $request)
{
$id = $request->getAttribute('id');
return sqliteConnection()
->query(
'DELETE FROM tasks WHERE id = ?',
[$id]
)
->then(function (Result $result) {
return new Response(
301,
[
'Location' => '/tasks'
],
$result->changed ? 'deleted' : 'not found'
);
});
}
//// .... The repository is here -> https://github.com/mahmutbayri/framework-x-database-crud My question is whether we have a cleaner method. Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
@mahmutbayri Your code looks fine, nothing wrong with that 👍 @clue and I have a similar approach as #76 in mind. We think that this should be part of reactphp/http and look something like this: Something is coming up soon 🔥 |
Beta Was this translation helpful? Give feedback.
@mahmutbayri Your code looks fine, nothing wrong with that 👍
@clue and I have a similar approach as #76 in mind. We think that this should be part of reactphp/http and look something like this:
React\Http\Message\Response::redirect($url)
.Something is coming up soon 🔥