getAttribute('cloud_actor') ?? CloudAccess::actor(false); if ($idempotent) { $key = trim((string) $request->getHeaderLine('Idempotency-Key')); if (preg_match('/^[A-Za-z0-9_.-]{16,128}$/D', $key) !== 1) { throw new CloudError('请求幂等标识无效', 400); } $actor['request_idempotency_key'] = $key; } return $actor; } public function index($request, $response) { $method = strtoupper((string) $request->getMethod()); $actor = $this->actor($request, $method === 'POST'); if ($method === 'GET') { $result = CloudVpcService::library($actor); $status = 200; } else { $body = CloudInput::object($request); $result = CloudVpcService::create($actor, $body); $status = 201; } return $response->withJson($result, $status) ->withHeader('Cache-Control', 'private, no-store'); } public function delete($request, $response, $args) { $actor = $this->actor($request); return $response->withJson(CloudVpcService::delete( $actor, (string) ($args['vpc_key'] ?? '') ))->withHeader('Cache-Control', 'private, no-store'); } }