Is it possible to use wildcards in API paths in IBM API Connect

微笑、不失礼 提交于 2019-12-08 12:04:14

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!