diff --git a/src/Kernel/BaseClient.php b/src/Kernel/BaseClient.php index b4c257d..2062100 100644 --- a/src/Kernel/BaseClient.php +++ b/src/Kernel/BaseClient.php @@ -221,6 +221,11 @@ protected function registerHttpMiddlewares() $this->pushMiddleware($this->jaegerMiddleware(), 'jaeger'); } + // tap + if ($this->app['config']->has('tap')) { + $this->pushMiddleware($this->tapMiddleware(), 'tap'); + } + // log $this->pushMiddleware($this->logMiddleware(), 'log'); } @@ -259,6 +264,19 @@ protected function jaegerMiddleware() }); } + /** + * Middleware that invokes a callback before and after sending a request. + * + * @return \Closure + */ + protected function tapMiddleware() + { + return Middleware::tap( + is_callable($before = $this->app['config']->get('tap.before')) ? $before : null, + is_callable($after = $this->app['config']->get('tap.after')) ? $after : null + ); + } + /** * Extra request params. *