问题
I have a requirement to route all the API calls which meets some pattern, to a specific service. For example "/register/student", "register/teacher", "register/employee" should all go to one micro service. Can I define the above path (not absolute path for each API) using some wild card or pattern so that any request which matches the patter: "/register/**", should go to one specific micro service.
回答1:
You can do it in the path definition using path parameters and operation switches to control the flow of various patterns.
paths:
'register/{myParam}':
get:
responses:
'200':
description: 200 OK
parameters:
- name: myParam
type: string
in: path
required: true
回答2:
Hi you can create a "Base Path" "/resgister" , then you can create the path "strong text/" asociated with some http method (get, post,...). Then in the you can usae javascript/gatewayscrip and some regex to filter $(request.path) and $(request.search) for your logic.
But if you whant to send all the request to some unique specific micro service, you only need to do the first part of the path and then use a "Proxy" politic.
来源:https://stackoverflow.com/questions/51187059/is-it-possible-to-use-wildcards-in-api-paths-in-ibm-api-connect