Middleware no longer takes a Pipeline. pipeline
authorRobert Sesek <rsesek@bluestatic.org>
Sun, 4 Dec 2016 04:56:40 +0000 (23:56 -0500)
committerRobert Sesek <rsesek@bluestatic.org>
Sat, 18 Nov 2017 20:13:52 +0000 (15:13 -0500)
http2/action.php
http2/middleware.php
http2/pipeline.php
http2/router.php

index 68a8788076dd21d890f32ac74aeb2109a8cae44f..4b14e531834d3f2afe03d0496ce9650d09ca28ef 100644 (file)
@@ -41,7 +41,7 @@ class Action extends Middleware {
       return $this->defaultRequest($request);
     }
 
-    $response = $this->{$action}();
+    $response = $this->{$action}($request);
 
     $this->afterRequest($response);
 
index 4e51841d245b59c7b24e719640a6aaeb8a750061..c393d46b33e7d617335ca148fc4fb3c5d0589f21 100644 (file)
@@ -21,12 +21,9 @@ require_once HOPLITE_ROOT . '/http2/request.php';
 require_once HOPLITE_ROOT . '/http2/response.php';
 
 abstract class Middleware {
-  protected $pipeline;
   protected $next;
 
-  public function __construct(Pipeline $pipeline,
-                              Middleware $next) {
-    $this->pipeline = $pipeline;
+  public function __construct(Middleware $next) {
     $this->next = $next;
   }
 
@@ -48,10 +45,9 @@ class Sentinel extends Middleware {
 class ClosureMiddleware extends Middleware {
   private $closure;
 
-  public function __construct(Pipeline $pipeline,
-                              Middleware $next,
+  public function __construct(Middleware $next,
                               \Closure $closure) {
-    parent::__construct($pipeline, $next);
+    parent::__construct($next);
     $this->closure = $closure;
   }
 
index 96c1e2f1aa737a252976250330ef2a9f12d9f234..ffd015415ac3ac5d2ce4fa079354dc2af89b5b10 100644 (file)
@@ -40,15 +40,15 @@ class Pipeline {
 
   public function buildMiddleware($args, $next) {
     if ($args instanceof \Closure) {
-      return new ClosureMiddleware($this, $next, $args);
+      return new ClosureMiddleware($next, $args);
     } else if ($args instanceof Pipeline) {
       return $args->_build($next);
     } else if (is_array($args)) {
       $class = array_shift($args);
-      array_unshift($args, $this, $next);
+      array_unshift($args, $next);
       return new $class(...$args);
     } else {
-      return new $args($this, $next);
+      return new $args($next);
     }
   }
 
index d991add195e2f9e6834303d8deb019cdf8ac34c3..352a8b28e40a93a610b28c0974d77b047dced850 100644 (file)
@@ -35,11 +35,10 @@ class Router extends Middleware {
   private $map;
   private $subpipe;
 
-  public function __construct(Pipeline $pipeline,
-                              Middleware $next,
+  public function __construct(Middleware $next,
                               RouteMap $map,
                               Pipeline $subpipe=NULL) {
-    parent::__construct($pipeline, $next);
+    parent::__construct($next);
     $this->map = $map;
     $this->subpipe = $subpipe ? $subpipe : new Pipeline();
   }