다음을 통해 공유


모의 nth 요청

Dev Proxy는 요청 객체의 nth 속성을 통해 요청의 n번째 시뮬레이션을 지원합니다.

팁 (조언)

명령 프롬프트 devproxy config get microsoft-graph-connector실행하여 이 사전 설정을 다운로드합니다.

예를 들어 다음 모의 파일을 사용하면 동일한 요청 URL에 대한 두 개의 모의 파일이 포함되어 있음을 알 수 있습니다. 지정된 URL의 요청을 두 번째로 가로챌 때 프록시는 nth 속성을 사용하는 첫 번째 응답을 사용합니다. 다른 모든 요청의 경우 프록시는 두 번째 응답을 반환합니다.

팁 (조언)

속성을 가진 모의 객체가 먼저 있어야 합니다 nth. 프록시는 첫 번째 일치 항목을 기반으로 모의 개체를 사용합니다.

{
  "$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v1.0.0/mockresponseplugin.schema.json",
  "mocks": [
    {
      "request": {
        "url": "https://graph.microsoft.com/v1.0/external/connections/*/operations/*",
        "method": "GET",
        "nth": 2
      },
      "response": {
        "statusCode": 200,
        "body": {
          "id": "1.neu.0278337E599FC8DBF5607ED12CF463E4.6410CCF8F6DB8758539FB58EB56BF8DC",
          "status": "completed",
          "error": null
        }
      }
    },
    {
      "request": {
        "url": "https://graph.microsoft.com/v1.0/external/connections/*/operations/*",
        "method": "GET"
      },
      "response": {
        "statusCode": 200,
        "body": {
          "id": "1.neu.0278337E599FC8DBF5607ED12CF463E4.6410CCF8F6DB8758539FB58EB56BF8DC",
          "status": "inprogress",
          "error": null
        }
      }
    }
  ]
}

다음 단계

MockResponsePlugin에 대해 자세히 알아봅니다.

샘플

관련 개발 프록시 샘플도 참조하세요.