Example #1
0
 public function call(Server\Request $req = null, Server\Error $err = null)
 {
     d('CALLING URI WRITER (#1)');
     $res = parent::call($req, $err);
     $res->write('<p>URI: ' . $req->uri . '</p>');
     return $res;
 }
 public function call(Server\Request $req = null, Server\Error $err = null)
 {
     $res = parent::call($req, $err);
     // $res->write('gzip:');
     $res->body = '<pre style="border: 3px solid #f00; padding: 1em;">' . $res->body . '</pre>';
     return $res;
 }
<?php

putenv('DEBUG=1');
require __DIR__ . '/../vendor/autoload.php';
// class CustomMiddleware extends Server\Layer
// {
//     public function call(Server\Request $req = null, Server\Error $err = null)
//     {
//         $res = parent::call($req, $err);
//         $res->write('<h1>Hello, world!</h1>');
//         return $res;
//     }
// }
// $app = new Server\Module(null, array(), $_SERVER);
// $app->employ([
//     'class' => 'CustomMiddleware',
// ]);
// $res = $app->call(new Server\Request(
//     $_SERVER['REQUEST_METHOD'],
//     $_SERVER['REQUEST_URI']
// ));
//$res->send(); // outputs: <h1>Hello, world!</h1>
// d($app);
// $res = $app->call();
// d()
$layer = new Server\Layer(new Server\Layer());
d($layer->dump());
$res = $layer->call(new Server\Request($_SERVER['REQUEST_METHOD'], $_SERVER['REQUEST_URI'], array('test' => '1'), array('Accept' => 'text/html')));
d($res);
Example #4
0
 public function call(Server\Request $req = null, Server\Error $err = null)
 {
     $res = parent::call($req, $err);
     $res->write($this->config['body'] ? $this->config['body'] : 'test-layer');
     return $res;
 }
 public function call(Server\Request $req = null, Server\Error $err = null)
 {
     $res = parent::call($req, $err);
     $res->body = '<h1>' . $res->body . '</h1>';
     return $res;
 }