<?php

namespace Shm\ShmUtils;

use Shm\ShmCmd\Cmd;

class RedirectRoute
{
    public static function init(): void
    {

        if (Cmd::cli()) {
            return;
        }

        $f3 = \Base::instance();

        $f3->route('GET /redirect', function ($f3) {
            $url = $_GET['to'] ?? '';
            if ($url) {
                header("Location: $url");
                exit;
            }
        });
    }
}
