use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
class IndexController implements RequestHandlerInterface
{
public function handle(ServerRequestInterface $request): ResponseInterface
{
$route = $request->getUri()->getPath();
if (Str::startsWith($route, '/admin')) {
$file = 'admin.html';
} else {
$isMobile = $this->isMobile($request->getServerParams());
$file = $isMobile ? 'index.html' : 'pc.html';
if (Arr::has($request->getQueryParams(), 'from')) {
$file = 'index.html';
}
if (!$isMobile && Str::startsWith($route, '/pages')) {
$file = Str::replaceFirst("/pages", "/pc-pages", $route) . "/index.html";
}
}
return DiscuzResponseFactory::FileResponse(
public_path($file)
);
}
}
handle这个函数, 参数$request前面加了一串ServerRequestInterface是什么作用? 返回又定义了:ResponseInterface又有什么用。 是新语法吗