microgateway icon indicating copy to clipboard operation
microgateway copied to clipboard

User defined policies

Open ghost opened this issue 7 years ago • 3 comments

Hi Strongloop Team,

I really like how API Connect's API Designer play well with microgateway. I have followed this tutorial and the readme. The tutorial suggested to put the user defined policies inside a "policies" folder and configure the ".apiconnect > config" to refer to this folder.

My question is... Is there a way I can config where the microgateway (not API Connect/API Designer) to grab the user defined policies?

The reason I am asking is.. I try to something as below: (1) Follow the "readme" tutorial, in which those built-in policies are clone to my local environment (2) Go to the project's root and "apic edit" (3) Configure the ".apiconnect > config" to let API Connect know where my custom policies are stored (3) Use the API Designer's "Assemble" and pull the "JavaScript" to the panel (4) [Problem arises here!] API Designer said "This policy is not available on the selected gateway"

I try to put my custom policies in another folder "self-defined-policies" and configure the ".apiconnect > config" to read "self-defined-policies". After that, API Connect can read the policies properly (without saying "This policy is not available on the selected gateway") However when I run "sample.js" in the "readme" tutorial, it fails to reference my custom policies..

Thanks for your help

ghost avatar Jul 02 '17 10:07 ghost

In step 3), the ./apiconfig/connect directory is a directory reference to a policies directory. In the tutorial, the path was relative to the policies directory.

You only need the API Connect designer to view them in the Assembly, so I assume your question is about packaging them for deployment?

ozairs avatar Jul 10 '17 20:07 ozairs

Yes.. especially about packaging and deploying the "userPolicies".

I have some new findings. Just want to confirm am I correct. Finding: microgateway will actually reference the .apiconnect/config to find the "userPolicies" (just like API Connect designer).

Trial 1:

  1. Inside .apiconnect/config, I type { userPolicies: ["self-defined-policies"] }
  2. I copy rate-limiting from policies to self-defined-policies
  3. I type node sample.js in the command prompt

Result: It warns me that Duplicate policy version (rate-limiting:1.0.0) found at: C:/Users/ahwing210/Desktop/testing/api-gateway/self-defined-policies/rate-limiting - skipping

Trial 2:

  1. I remove { userPolicies: ["self-defined-policies"] } from .apiconnect/config.
  2. I copy rate-limiting from policies to self-defined-policies
  3. I type node sample.js in the command prompt

Result: It doesn't warn me anything

ahwing210 avatar Jul 11 '17 05:07 ahwing210

Do you also have policies defined at some other location? perhaps in your home directory?

ozairs avatar Jul 16 '17 16:07 ozairs