for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the DigitalOceanV2 library.
*
* (c) Antoine Corcy <[email protected]>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace DigitalOceanV2\Adapter;
use Buzz\Middleware\MiddlewareInterface;
use Psr\Http\Message\RequestInterface;
use Psr\Http\Message\ResponseInterface;
/**
* @author Antoine Corcy <[email protected]>
* @author Graham Campbell <[email protected]>
class BuzzOAuthMiddleware implements MiddlewareInterface
{
* @var string
protected $token;
* @param string $token
public function __construct($token)
$this->token = $token;
}
public function handleRequest(RequestInterface $request, callable $next)
return $next($request->withHeader('Authorization', sprintf('Bearer %s', $this->token)));
public function handleResponse(RequestInterface $request, ResponseInterface $response, callable $next)
return $next($request, $response);