Conditional Field Extraction
Uses the condition system to apply json_body_field only on specific request paths
Category: Practical
Task: Uses the condition system to apply json_body_field only on specific request paths
Prerequisites: The product runtime and any backend services referenced by this configuration.
Run it: Use ghcr.io/praxis-proxy/praxis:0.7.2 and follow the first reverse-proxy tutorial to mount and start the configuration.
This configuration comes from the selected release. The example has not been run here; external services are not bundled.
Download the source file.
# Conditional Field Extraction
#
# Uses the condition system to apply json_body_field only on
# specific request paths. Requests to /v1/ get the "model"
# field extracted into X-Model; all other paths skip body
# inspection entirely, avoiding unnecessary buffering.
#
# This is useful when a single gateway serves both AI
# inference endpoints (which need body-based routing) and
# static or administrative endpoints (which do not).
#
listeners:
- name: gateway
address: "0.0.0.0:8080" # dev value; binds all interfaces
filter_chains:
- conditional-extraction
- routing
filter_chains:
- name: conditional-extraction
filters:
- filter: json_body_field
conditions:
- when:
path_prefix: "/v1/"
field: model
header: X-Model
- name: routing
filters:
- filter: router
routes:
- path_prefix: "/v1/"
headers:
x-model: "model-beta-1"
cluster: beta_cluster
- path_prefix: "/v1/"
cluster: default-inference
- path_prefix: "/"
cluster: static
- filter: load_balancer
clusters:
- name: beta_cluster
endpoints:
- "10.0.1.1:8080"
- name: default-inference
endpoints:
- "10.0.2.1:8080"
- name: static
endpoints:
- "10.0.3.1:8080"