RouteFilter to rewrite path using regular expressions

RouteFilter Regex Rewrite

Perform a regular expression based rewrite of path using this filter.

Filter Config


apiVersion: enroute.saaras.io/v1
kind: RouteFilter
metadata:
  name: regex-rewrite-filter
  namespace: httpbin
spec:
  name: regex-rewrite-filter
  type: route_filter_regex_rewrite
  routeFilterConfig:
    config: |
          {
                "pattern" : "/api/(.*)",
                "substitution" : "/v1/\\1"
          }

In the example above, an incoming path of form /api/get gets tranformed into /v1/get

Example GatewayHost Config

apiVersion: enroute.saaras.io/v1
kind: GatewayHost
metadata:
  labels:
    app: httpbin
  name: httpbin-9000-gatewayhost-httpbin-host
  namespace: httpbin
spec:
  routes:
  - conditions:
    - prefix: /
    filters:
    - name: regex-rewrite-filter
      type: route_filter_regex_rewrite
    services:
    - name: httpbin
      port: 9000
  virtualhost:
    fqdn: '*'