<?php

namespace Licenzo\Framework\Contracts\Http;

use Licenzo\Framework\Http\Request;
use Licenzo\Framework\Http\Response;

// Prevent direct access
if (!defined('ABSPATH')) {
    exit;
}

/**
 * Terminable Middleware Contract
 *
 * This interface defines the contract for middleware that need to perform
 * cleanup tasks after the response has been sent to the user.
 */
interface TerminableMiddleware
{
    /**
     * Perform any final work for the request lifecycle.
     *
     * This method is called after the response has been sent to the user.
     * Use this method to perform cleanup tasks such as:
     * - Closing database connections
     * - Clearing temporary data
     * - Logging request information
     * - Releasing resources
     *
     * @param Request $request The original request
     * @param Response $response The response that was sent
     * @return void
     */
    public function terminate(Request $request, Response $response): void;
}
