Skip to content

Commit

Permalink
Merge pull request #9 from freyo/dev
Browse files Browse the repository at this point in the history
add tag middleware
  • Loading branch information
freyo committed Aug 18, 2020
2 parents e2096a6 + 7df8e89 commit 4ef8f1b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/Kernel/BaseClient.php
Expand Up @@ -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');
}
Expand Down Expand Up @@ -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.
*
Expand Down

0 comments on commit 4ef8f1b

Please sign in to comment.