<?php

namespace lib\Core\Middlewares;

use lib\Core\Middlewares\MiddlewareInterface;
use lib\Core\Http\Response;

class AuthMiddleware implements MiddlewareInterface
{
  public function handle(array $params, callable $next)
  {
    // 간단한 인증 체크 예시: token 값이 'secret'이 아니면 거부
    if (!isset($params['token']) || $params['token'] !== 'secret') {
      Response::json(['error' => 'Unauthorized'], 401);
      return;
    }
    return $next($params);
  }
}
