]>
src.bluestatic.org Git - hoplite.git/blob - middleware.php
4e51841d245b59c7b24e719640a6aaeb8a750061
3 // Copyright (c) 2016 Blue Static
5 // This program is free software: you can redistribute it and/or modify it
6 // under the terms of the GNU General Public License as published by the Free
7 // Software Foundation, either version 3 of the License, or any later version.
9 // This program is distributed in the hope that it will be useful, but WITHOUT
10 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14 // You should have received a copy of the GNU General Public License along with
15 // this program. If not, see <http://www.gnu.org/licenses/>.
17 namespace hoplite\http2
;
19 require_once HOPLITE_ROOT
. '/http2/pipeline.php';
20 require_once HOPLITE_ROOT
. '/http2/request.php';
21 require_once HOPLITE_ROOT
. '/http2/response.php';
23 abstract class Middleware
{
27 public function __construct(Pipeline
$pipeline,
29 $this->pipeline
= $pipeline;
33 public abstract /*http\Response*/ function execute(Request
$request);
36 class Sentinel
extends Middleware
{
39 public function __construct(Response
$response) {
40 $this->response
= $response;
43 public function execute(Request
$request) {
44 return $this->response
;
48 class ClosureMiddleware
extends Middleware
{
51 public function __construct(Pipeline
$pipeline,
54 parent
::__construct($pipeline, $next);
55 $this->closure
= $closure;
58 public function execute(Request
$request) {
59 $closure = $this->closure
;
60 return $closure($request, $this->next
);