RedirectTo GatewayFilter ファクトリ
RedirectTo GatewayFilter ファクトリは 3 つのパラメーター status、url、オプションで includeRequestParams を取ります。status パラメーターは、301 などの 300 シリーズリダイレクト HTTP コードである必要があります。url パラメーターは有効な URL である必要があります。これは Location ヘッダーの値です。includeRequestParams パラメーターは、リクエストクエリパラメーターを url に含める必要があるかどうかを示します。設定されていない場合は、false として扱われます。相対リダイレクトの場合は、ルート定義の URI として uri: no://op を使用する必要があります。次のリストは RedirectTo GatewayFilter を構成します。
application.yml
spring:
cloud:
gateway:
routes:
- id: prefixpath_route
uri: https://example.org
filters:
- RedirectTo=302, https://acme.org これにより、Location:https://acme.org ヘッダー付きのステータス 302 が送信され、リダイレクトが実行されます。
次の例では、includeRequestParams を true に設定して RedirectTo GatewayFilter を構成します。
application.yml
spring:
cloud:
gateway:
routes:
- id: prefixpath_route
uri: https://example.org
filters:
- RedirectTo=302, https://acme.org, true クエリ ?skip=10 を含むリクエストがゲートウェイに対して行われると、ゲートウェイはリダイレクトを実行するために Location:https://acme.org?skip=10 ヘッダーを含むステータス 302 を送信します。