how to create a task request (mail webservice) in order to not wait for response and continue code execution, like:
class HomePageHandler implements RequestHandlerInterface{
public function handle(ServerRequestInterface $request): ResponseInterface
{
$_post = $request->getParsedBody();
if( isset($_post['email']) ){
/**
* send async request and do not wait it!
*/
$client = new Client();
$client->setUri("https://mail-api-srv:9501/api/mail");
$client->setMethod("GET");
$client->setParameterGet(['mail'=>$_post['mail'],'action'=>'recoveryAccount']);
$responseMail = $client->send();
// no need get body
#$body = $responseMail->getBody();
}
// continue code execution, do not wait response from MAIL API
// Example
// save user action into DB
$this->tableGateway->save(
[
'mail'=>$_post,
'action'=>'recoveryAccount'
]
);
// return message to user, and mail microservice is processing the request
return new JsonResponse(['message'=>'Check your inbox/spam folder'],200);
}
}