summaryrefslogtreecommitdiff
path: root/tests/worker-deny.php
diff options
context:
space:
mode:
Diffstat (limited to 'tests/worker-deny.php')
-rw-r--r--tests/worker-deny.php30
1 files changed, 30 insertions, 0 deletions
diff --git a/tests/worker-deny.php b/tests/worker-deny.php
new file mode 100644
index 00000000..6dc993f6
--- /dev/null
+++ b/tests/worker-deny.php
@@ -0,0 +1,30 @@
+<?php
+/**
+ * @var Goridge\RelayInterface $relay
+ */
+use Spiral\Goridge;
+use Spiral\RoadRunner;
+
+ini_set('display_errors', 'stderr');
+require __DIR__ . "/vendor/autoload.php";
+
+$worker = new RoadRunner\Worker(new Goridge\StreamRelay(STDIN, STDOUT));
+$psr7 = new RoadRunner\Http\PSR7Worker(
+ $worker,
+ new \Nyholm\Psr7\Factory\Psr17Factory(),
+ new \Nyholm\Psr7\Factory\Psr17Factory(),
+ new \Nyholm\Psr7\Factory\Psr17Factory()
+);
+
+while ($req = $psr7->waitRequest()) {
+ try {
+ $resp = new \Nyholm\Psr7\Response();
+ if ($req->getAttribute('ws:joinServer')) {
+ $psr7->respond($resp->withStatus(200));
+ } else {
+ $psr7->respond($resp->withStatus(401));
+ }
+ } catch (\Throwable $e) {
+ $psr7->getWorker()->error((string)$e);
+ }
+}