Closed geerteltink closed 8 years ago
@xtreamwayz thanks for the error report. I will have a look at it in the next couple of days (hopefully). Also thanks for the idea of an real PSR-7 request datacollector, that totally makes sense.
I am not able to reproduce the problem. These are the steps I took:
I registered a pre_routing middleware in config/autoload/middleware-pipeline.global.php
return [
'middleware_pipeline' => [
'pre_routing' => [
[
'middleware' => bitExpert\Http\Middleware\Psr7\Prophiler\ProphilerMiddleware::class,
],
],
'post_routing' => [
],
],
];
I added a factory definition for \bitExpert\Http\Middleware\Psr7\Prophiler\ProphilerMiddleware to config/autoload/dependencies.global.php
return [
'dependencies' => [
'invokables' => [
App\Action\PingAction::class => App\Action\PingAction::class,
],
'factories' => [
App\Action\HomePageAction::class => App\Action\HomePageFactory::class,
Zend\Expressive\Application::class => Zend\Expressive\Container\ApplicationFactory::class,
bitExpert\Http\Middleware\Psr7\Prophiler\ProphilerMiddleware::class => App\Middleware\ProphilerFactory::class
]
]
];
The \App\Middleware\ProphilerFactory looks like this:
namespace App\Middleware;
use Interop\Container\ContainerInterface;
class ProphilerFactory
{
public function __invoke(ContainerInterface $container)
{
$prophiler = new \Fabfuel\Prophiler\Profiler();
$toolbar = new \Fabfuel\Prophiler\Toolbar($prophiler);
return new \bitExpert\Http\Middleware\Psr7\Prophiler\ProphilerMiddleware($toolbar);
}
}
Thanx, it's working now after following these steps. Not sure what part I missed before.
As mentioned in zendframework/zend-expressive#181
If you return a HtmlResponse in an Action the application stops processing other middleware: example.
The solution that worked for me is wrapping the real app inside another debug app:
Also if it pretends to be PSR-7 compliant, it would be nice to have a real PSR-7 request datacollector.