RemoveJsonAttributesResponseBody GatewayFilter ファクトリ

RemoveJsonAttributesResponseBody GatewayFilter ファクトリは、検索する attribute names のコレクションを取得します。リストのオプションの最後のパラメーターは、ルートレベルで属性を削除するためのブール値にすることができます (パラメーター構成の最後に存在しない場合のデフォルト値 false)。または再帰的に (true)。属性を削除することにより、JSON 本文コンテンツに変換を適用する便利な方法を提供します。

次の例では、RemoveJsonAttributesResponseBody GatewayFilter を構成します。

application.yml
spring:
  cloud:
    gateway:
      routes:
      - id: removejsonattributes_route
        uri: https://example.org
        filters:
        - RemoveJsonAttributesResponseBody=id,color

これにより、ルートレベルの JSON コンテンツボディから属性 "id" と "color" が削除されます。

次の例では、オプションの最後のパラメーターを使用する RemoveJsonAttributesResponseBody GatewayFilter を構成します。

application.yml
spring:
  cloud:
    gateway:
      routes:
      - id: removejsonattributes_recursively_route
        uri: https://example.org
        predicates:
        - Path=/red/{segment}
        filters:
        - RemoveJsonAttributesResponseBody=id,color,true

これにより、任意のレベルで JSON コンテンツ本体から属性 "id" と "color" が削除されます。