diff options
Diffstat (limited to 'services/app/src/Middlewares/CacheControlPrivateMiddleware.php')
| -rw-r--r-- | services/app/src/Middlewares/CacheControlPrivateMiddleware.php | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/services/app/src/Middlewares/CacheControlPrivateMiddleware.php b/services/app/src/Middlewares/CacheControlPrivateMiddleware.php new file mode 100644 index 0000000..4372d5c --- /dev/null +++ b/services/app/src/Middlewares/CacheControlPrivateMiddleware.php @@ -0,0 +1,23 @@ +<?php + +declare(strict_types=1); + +namespace Nsfisis\Albatross\Middlewares; + +use Psr\Http\Message\ResponseInterface; +use Psr\Http\Message\ServerRequestInterface; +use Psr\Http\Server\MiddlewareInterface; +use Psr\Http\Server\RequestHandlerInterface; + +final class CacheControlPrivateMiddleware implements MiddlewareInterface +{ + public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface + { + $response = $handler->handle($request); + if ($request->getAttribute('current_user') !== null) { + return $response->withHeader('Cache-Control', 'private'); + } else { + return $response; + } + } +} |
