<?php

use Psr\Http\Message\ResponseInterface as Response;
use Psr\Http\Message\ServerRequestInterface as Request;

$app->get('/debug', function (Request $request, Response $response) {
    $body = "URI Path: " . $request->getUri()->getPath() . "\n";
    $body .= "REQUEST_URI: " . ($_SERVER['REQUEST_URI'] ?? 'N/A') . "\n";
    $body .= "SCRIPT_NAME: " . ($_SERVER['SCRIPT_NAME'] ?? 'N/A') . "\n";
    $body .= "REDIRECT_URL: " . ($_SERVER['REDIRECT_URL'] ?? 'N/A') . "\n";
    
    $response->getBody()->write($body);
    return $response->withHeader('Content-Type', 'text/plain');
});
