reverse-proxy icon indicating copy to clipboard operation
reverse-proxy copied to clipboard

What should be the route for passing Id as well.

Open kidkai25 opened this issue 5 years ago • 2 comments

Some details

How many backends are in your application?

  • [ ] 1-2

Of all the examples I have seen, none of them showed how can I configure a route for something like api/EmployeesService/1

      "route2": {
      "ClusterId": "cluster2",
      "Match": {        
        "Path": "/api/employeesservice/{Id}"
      },
      "Transforms": [
        {
          "PathRemovePrefix": "/api/employeesservice/{Id}"
        }
      ]
    }
  },
    "Clusters": {    
      "cluster2": {
        "Destinations": {
          "cluster2/destination2": {
            "Address": "http://localhost:90/api/employees/{Id}"
        }
       }
      }
}

I am still new in web programming. So please forgive me if this is a stupid question.

kidkai25 avatar Jun 11 '21 05:06 kidkai25

Try this: https://microsoft.github.io/reverse-proxy/articles/transforms.html#pathpattern

      "route2": {
      "ClusterId": "cluster2",
      "Match": {        
        "Path": "/api/employeesservice/{id}"
      },
      "Transforms": [
        {
          "PathPattern": "/api/employees/{id}"
        }
      ]
    }
  },
    "Clusters": {    
      "cluster2": {
        "Destinations": {
          "cluster2/destination2": {
            "Address": "http://localhost:90"
        }
       }
      }
}

Or:

      "route2": {
      "ClusterId": "cluster2",
      "Match": {        
        "Path": "/api/employeesservice/{**catch-all}"
      },
      "Transforms": [
        {
          "PathRemovePrefix": "/api/employeesservice"
        },
        {
          "PathPrefix": "/api/employees"
        }
      ]
    }
  },
    "Clusters": {    
      "cluster2": {
        "Destinations": {
          "cluster2/destination2": {
            "Address": "http://localhost:90"
        }
       }
      }
}

Tratcher avatar Jun 11 '21 15:06 Tratcher

thanks a lot :))

kidkai25 avatar Jun 13 '21 08:06 kidkai25