microgateway
microgateway copied to clipboard
User defined policies
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
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?
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:
- Inside
.apiconnect/config
, I type{ userPolicies: ["self-defined-policies"] }
- I copy
rate-limiting
frompolicies
toself-defined-policies
- 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:
- I remove
{ userPolicies: ["self-defined-policies"] }
from.apiconnect/config
. - I copy
rate-limiting
frompolicies
toself-defined-policies
- I type
node sample.js
in the command prompt
Result: It doesn't warn me anything
Do you also have policies defined at some other location? perhaps in your home directory?