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 @@ +