<?php
namespace ProVM\NotariaRaby\Common\Middleware;

use Psr\Http\Message\ServerRequestInterface as Request;
use Psr\Http\Server\RequestHandlerInterface as Handler;
use Psr\Http\Message\ResponseInterface as Response;
use Psr\Container\ContainerInterface as Container;

class Blade {
  protected $container;
  public function __construct(Container $container) {
    $this->container = $container;
  }
  public function __invoke(Request $request, Handler $handler): Response {
    $folder = $this->container->get('folders.cache');
    if (!file_exists($folder)) {
      mkdir($folder);
    }
    return $handler->handle($request);
  }
}
