websocket-upgrade
WebSocket 연결을 통해 API 요청 및 응답을 처리하려면 websocket-upgrade 정책을 사용하십시오.
게이트웨이 지원
| 게이트웨이 | 정책 버전 |
|---|---|
| DataPower® API Gateway | 2.0.0 |
이 항목에서는 OpenAPI 소스에서 정책을 구성하는 방법을 설명합니다. 어셈블리 사용자 인터페이스에서 정책을 구성하는 방법에 대한 자세한 내용은 Websocket 업그레이드를 참조하십시오.
websocket-upgrade 정책의 형식은 다음과 같습니다.
- websocket-upgrade:
version: version
title: title
description: description
target-url: URL_of_target_API
tls-profile: TLS_profile_to_be_used
timeout: timeout_value_in_seconds
follow-redirects: redirect_behavior_on_301_error
username: username_if_authentication_required
password: password_if_authentication_required
inject-proxy-headers: are_proxy_headers_sent_to_target_url
decode-request-params: are_request_parameters_decoded
encode-plus-char: are_plus_characters_encoded
header-control:
.
.
.
headers_to_copy_to_target_url
.
.
.
parameter-control:
.
.
.
parameters_to_copy_to_target_url
.
.
.
특성
| 특성 | 필수 | 설명 | 데이터 유형 |
|---|---|---|---|
| version | 예 | 정책 버전 번호입니다. | 문자열 |
| title | 아니오 | 해당 정책의 제목입니다. | 문자열 |
| description | 아니오 | 정책의 설명입니다. | 문자열 |
| target-url | 예 | 호출될 URL을 지정합니다. | 문자열 |
| tls-profile | 아니오 | 데이터의 보안 전송을 위해 사용할 TLS 프로파일을 지정합니다. | 문자열 |
| timeout | 아니오 | 엔드포인트의 응답을 기다리는 시간입니다(단위: 초). 기본값은 |
정수 |
| follow-redirects | 아니오 | 백엔드 서버가 HTTP 상태 코드를 반환하는 경우의 동작을 지정합니다. 301 Moved
Permanently. 이 특성이 true로 설정되면 invoke 정책이 응답의 Location 헤더에 지정된 URL에 대한 추가 호출을 작성하여 URL 경로 재지정을 따릅니다. 이 특성이 false로 설정되면 invoke가 301 상태 코드를 저장하고 API 호출이 완료된 것으로 간주됩니다.참고: follow-redirect 특성은 DataPower API Gateway에서만 지원됩니다. 를 DataPower Gateway (v5 compatible)사용하는 경우, 는 invoke 항상 URL 리디렉션을 따릅니다. 반면 (에서는 지원되지 proxyDataPower API Gateway 않음) 정책은 상태 301 코드를 저장하고 URL 리디렉션을 따르지 않은 채 API 호출을 완료합니다. |
부울 |
| username | 아니오 | HTTP 기본 인증에 사용할 사용자 이름입니다. | 문자열 |
| password | 아니오 | HTTP 기본 인증에 사용할 비밀번호입니다. | 문자열 |
| inject-proxy-headers | 아니오 | true로 설정된 경우 invoke 정책이 target-url에 전송된 요청에
X-Forwarded-For, X-Forwarded-To, X-Forwarded-Host 및
X-Forwarded-Proto 헤더를 삽입합니다.기본값은 |
부울 |
| decode-request-params | 아니오 | true로 설정된 경우 호출 정책의 target-url에 대한 변수 정의에서 참조되는 요청 매개변수는 URL로 디코딩됩니다.기본값은 |
부울 |
| encode-plus-char | 아니오 | true로 설정된 경우 target-url의 조회 매개변수 값에 있는 모든 "+" 문자는 %2F로 인코딩됩니다.기본값은 |
부울 |
|
아니오 | 대상 URL에 복사할 message.headers의 헤더를 지정합니다.
values 특성에 나열되는 항목은 정규식 형식입니다. 값은 대소문자를 구분하지 않습니다. header-control 특성의 기본값은 다음과 같습니다.헤더 제어 예제 를 참조하십시오. |
오브젝트 |
|
아니오 | 대상 URL에 복사할 수신 요청의 매개변수를 지정합니다.
values 특성에 나열되는 항목은 정규식 형식입니다. 값은 대소문자를 구분하지 않습니다. parameter-control 특성의 기본값은 다음과 같습니다.매개변수 제어 예제 를 참조하십시오. |
오브젝트 |
|
아니오 | 요청 처리 어셈블리입니다. execute 섹션에서 어셈블리 구성에 대한 세부사항은 실행을 참조하십시오. |
오브젝트 |
|
아니오 | 응답 처리 프로세스 어셈블리입니다. execute 섹션에서 어셈블리 구성에 대한 세부사항은 실행을 참조하십시오. |
오브젝트 |
예
- websocket-upgrade:
version: 2.0.0
title: websocket-upgrade
timeout: 60
target-url: 'https://my.websocket.upgrade.com'
secure-gateway: false
follow-redirects: true
inject-proxy-headers: true
decode-request-params: false
encode-plus-char: true
response-assembly:
execute:
- parse:
version: 2.0.0
title: parse
parse-settings-reference:
default: apic-default-parsesettings
description: Parse the response from the backend server
header-control 예
# copy all headers to the target URL
- invoke:
target-url: http://myhost/mypath
header-control:
type: blocklist
values: []
# copy all headers except X-Client-ID and Content-Type
- invoke:
target-url: http://myhost/mypath
header-control:
type: allowlist
values:
- ^X-Client-ID$
- ^Content-Type$
# copy no headers
- invoke:
target-url: http://myhost/mypath
header-control:
type: allowlist
values: []
# copy only the Content-Type header
- invoke:
target-url: http://myhost/mypath
header-control:
type: allowlist
values:
- ^Content-Type$
parameter-control 예
# copy no request parameters to the target URL
- invoke:
target-url: http://myhost/path?storeid=3
parameter-control:
type: allowlist
values: []
# append the petid parameter to the target URL
# if the incoming request is http://apigw/org/sandbox/petstore/base?petid=100&display=detailed,
# the target URL at runtime will be http://myhost/mypath?storeid=3&petid=100
- invoke:
target-url: http://myhost/path?storeid=3
parameter-control:
type: allowlist
values:
- ^petid$