Routes based on Query Parameters

Hi, I’m currently testing moving a complex proxy we have in Caddy to Kong API Gateway but I realized there are some limitation regarding the routing based on headers and query params. I looked everywhere for something similar but found nothing. Not even in the Enterprise plugins.

Basically I’m trying to do a routing based on a specific query param and a Header. In Caddy it looks like this:

rewrite /microservice {
if {query} match ?=.*treeView=false.*
if {>clientId} match CUSTOMER-.*
to microservice-b{1}

Which basically routes traffic going to /microservice to /microservice-b if there is a query param that matches treeView=false (regex) and if there is a header that matches CUSTOMER-abc (regex)

I’ve tried this in Kong:

  - /microservice(?<capturedData>(?=treeView=false).*)
  regex_priority: 2
  strip_path: false
  - name: request-transformer
      http_method: null
        uri: /microservice-b$(uri_captures['capturedData'])
    enabled: true

But I realized the regex in the paths field only apply and capture URI Paths and not parameters.
Any idea on how to achieve this?


1 Like

Was this achieved ? I have a similar requirement

© 2019 Kong Inc.    Terms  •  Privacy  •  FAQ