한눈에 보기
목표: 테스트를 위해 API 응답에 인공 대기 시간 추가
시간: 5분
플러그 인:LatencyPlugin
필수 구성 요소:개발 프록시 설정
개발자 프록시를 사용하면 LatencyPlugin을 사용하여 느린 API 응답을 시뮬레이션할 수 있습니다.
먼저 개발자 프록시 구성 파일에서 플러그 인을 사용하도록 설정합니다.
파일: devproxyrc.json
{
"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v2.0.0/rc.schema.json",
"plugins": [
{
"name": "LatencyPlugin",
"enabled": true,
"pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",
"configSection": "latencyPlugin"
}
],
"urlsToWatch": []
}
다음으로, API에 대해 시뮬레이션할 최소 및 최대 지연 시간(밀리초)을 지정합니다.
파일: devproxyrc.json
"latencyPlugin": {
"minMs": 200,
"maxMs": 10000
}
전체 구성 파일은 다음과 같습니다.
파일: devproxyrc.json
{
"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v2.0.0/rc.schema.json",
"plugins": [
{
"name": "LatencyPlugin",
"enabled": true,
"pluginPath": "~appFolder/plugins/DevProxy.Plugins.dll",
"configSection": "latencyPlugin"
}
],
"urlsToWatch": [
"https://api.example.com/*"
],
"latencyPlugin": {
"$schema": "https://raw.githubusercontent.com/dotnet/dev-proxy/main/schemas/v2.0.0/latencyplugin.schema.json",
"minMs": 200,
"maxMs": 10000
}
}
응답이 지연되면 개발자 프록시는 콘솔 출력에서 지연된 총 기간을 표시합니다.
참고하십시오
- LatencyPlugin - 전체 참조
- 임의 오류로 내 앱 테스트 - API 오류 시뮬레이션
- 용어집 - 개발자 프록시 용어
GitHub에서 Microsoft와 공동 작업
이 콘텐츠의 원본은 GitHub에서 찾을 수 있으며, 여기서 문제와 끌어오기 요청을 만들고 검토할 수도 있습니다. 자세한 내용은 참여자 가이드를 참조하세요.
Dev Proxy