From ec873145d207ff0a5f49458c4f48be67d310de7e Mon Sep 17 00:00:00 2001 From: Dave Mc Nicoll Date: Thu, 4 Jul 2019 13:27:49 -0400 Subject: [PATCH] - Small WIP of template and adjusted the composer.json allowing registration into the autoload --- composer.json | 7 ++++- src/JavascriptMiddleware.php | 10 ++++++- templates/xhr_debug.php | 54 ++++++++++++++++++++++++++++++++++++ 3 files changed, 69 insertions(+), 2 deletions(-) create mode 100644 templates/xhr_debug.php diff --git a/composer.json b/composer.json index 0e4da57..06889cf 100644 --- a/composer.json +++ b/composer.json @@ -10,5 +10,10 @@ "email": "info@mcnd.ca" } ], - "require": {} + "require": {}, + "autoload": { + "psr-4": { + "TheBugs\\": "src/" + } + } } diff --git a/src/JavascriptMiddleware.php b/src/JavascriptMiddleware.php index 658a6d3..c40cd51 100644 --- a/src/JavascriptMiddleware.php +++ b/src/JavascriptMiddleware.php @@ -21,10 +21,12 @@ class JavascriptMiddleware implements MiddlewareInterface "headers" => [ "User-Agent" => "TheBugs/1.0", ], + # Callable functions + "functions" => [] ]; /** - * Filter list, allows custom invokable + * Filter list, allows custom invokable too * @var array */ protected $filters = []; @@ -56,6 +58,12 @@ class JavascriptMiddleware implements MiddlewareInterface } } + foreach($this->filters['functions'] as $func) { + if ( $func->bindTo($this, $this)() ) { + return $handler->handle($request); + } + } + $this->throwError(json_decode($request->getBody(), true)); } diff --git a/templates/xhr_debug.php b/templates/xhr_debug.php new file mode 100644 index 0000000..ffdcaec --- /dev/null +++ b/templates/xhr_debug.php @@ -0,0 +1,54 @@ +