Apigee rest endpoint path mapping to custom path

做~自己de王妃 提交于 2020-03-05 04:04:27

问题


I have rest end point /admn_resource_manager.I have created a apigee proxy to expose this. I dont want to expose it like this to others as I want something like /adminmanager. Is there any way to map /adminmanager to /admn_resource_manager using Apigee.

end user would use http://someurl.apigee/adminmanager instead of http://someurl.apigee/admn_resource_manager

I explored KeyValueMapoperation and AssignMessage in Apigee. I am not sure if these are the right option to implement map path.I didn't get any example for this either.


回答1:


I think Apigee can do it.

When I was started Apigee I have learned and try to understand from the picture below. (I think it is describe the main concept of this platform)

From your scenario,

  • You can specify the URL that you wants client to call maybe someurl.apigee/adminmanager or something else
  • Apigee is a middle also known as a Gateway. When you received the request from client, you can manage whatever you want. Of course, including pass your client to other URL like someurl.apigee/admn_resource_manager . (You just assigned new url to that request)

Because I'm not an expert as well so, you this link below can explain you more information.

Link:Using Flow Variables




回答2:


The way you would think to do this would be to use the Assign Message policy and use the Set -> Path element. But this policy isn't currently working as designed for rewriting the proxy's target URL. See the Assign Message Guidance for more details.

To rewrite the incoming URL to a different target URL you can use the Assign Message Policy to set the entire URL (target.url) in the Target Endpoint flow, or you can use a JavaScript callout to set it. I chose to use a JavaScript callout because it gives a lot more control when rewriting the URL.

Here is an example project on Github I put together for this you can use to see how I did it. It uses the swapi.co api as the target endpoint. This proxy uses the Assign Message and JavaScript callout policies to rewrite the URL. Here's some details about it...

Proxy Endpoints

  • Create a proxy endpoint for each resource you are renaming.
  • This is where you setup the Assign Message policy to set the variables for the new path suffix.

Assign Message Policies

  • Set on the PreFlow of each proxy endpoint to set the targetPathSuffix and appendResourceIdToUrl (if needed) variables.

JavaScript Policy

  • Calls out to the URLRewrite.js file to execute the js code.
  • Set on the TargetEndpoints PreFlow and executes on each request
  • Uses the variables set in the Assign Message Policies to change the target.url variable.


来源:https://stackoverflow.com/questions/57283523/apigee-rest-endpoint-path-mapping-to-custom-path

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