for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* HTTP server replier
* User: moyo
* Date: 2018/6/6
* Time: 4:01 PM
*/
namespace Carno\HRPC\Handlers;
use Carno\Chain\Layered;
use Carno\Coroutine\Context;
use Carno\HTTP\Server\Connection;
use Throwable;
class ServerReplier implements Layered
{
* @param mixed $message
* @param Context $ctx
* @return mixed
public function inbound($message, Context $ctx)
return $message;
}
public function outbound($message, Context $ctx)
$this->replying($ctx);
* @param Throwable $e
* @throws Throwable
public function exception(Throwable $e, Context $ctx)
throw $e;
private function replying(Context $ctx) : void
* @var Connection $ingress
if (($ingress = $ctx->get(ServerWrapper::CONNECTION))
&& ($response = $ctx->get(ServerWrapper::RESPONDING))
) {
$ingress->reply($response);