다음을 통해 공유


모의 n번째 요청

Dev Proxy는 요청 개체의 속성을 통해 n번째 모의 nth 를 지원합니다.

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

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

속성이 있는 모의 개체가 nth 먼저여야 합니다. 프록시는 첫 번째 일치 항목에 따라 모의 항목을 사용합니다.

{
  "$schema": "https://raw.githubusercontent.com/microsoft/dev-proxy/main/schemas/v0.14.1/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에 대해 자세히 알아봅니다.

샘플

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