Skip to content

Instantly share code, notes, and snippets.

@Kaapiii
Last active November 4, 2019 16:39
Show Gist options
  • Save Kaapiii/e63140f0eff20f2e04c3dba35980913b to your computer and use it in GitHub Desktop.
Save Kaapiii/e63140f0eff20f2e04c3dba35980913b to your computer and use it in GitHub Desktop.
Test for Concrete5 ApiLoggerMiddleware
<?php
namespace Concrete\Core\Http\Middleware;
use Concrete\Core\Logging\Channels;
use Concrete\Core\Logging\LoggerAwareInterface;
use Concrete\Core\Logging\LoggerAwareTrait;
use Psr\Log\LoggerInterface;
use Symfony\Component\HttpFoundation\Request;
class ApiLoggerMiddleware implements MiddlewareInterface, LoggerAwareInterface
{
use LoggerAwareTrait;
/**
* @var LoggerInterface
*/
protected $logger;
/**
* ApiLoggerMiddleware constructor.
* @param LoggerInterface $logger
*/
public function __construct(LoggerInterface $logger)
{
$this->logger = $logger;
}
/**
* @return string
*/
public function getLoggerChannel()
{
return Channels::CHANNEL_API;
}
/**
* Process the request and return a response
* @param \Symfony\Component\HttpFoundation\Request $request
* @param DelegateInterface $frame
* @return \Symfony\Component\HttpFoundation\Response
*/
public function process(Request $request, DelegateInterface $frame)
{
$this->logger->debug($request->headers);
return $frame->next($request);
}
}
# forward Authorization headers on revers proxy
location / {
try_files $uri $uri/ /index.php?$query_string;
proxy_set_header Authorization $http_authorization;
proxy_pass_header Authorization;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment