Last active
October 10, 2017 13:10
-
-
Save gunzip/f29b7854020dfcfd2a298a8a9a56ec32 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<policies> | |
<inbound> | |
<base /> | |
<set-variable name="Channel" value=" | |
@{ | |
try { | |
var request = context.Request.Body.As<JObject>(); | |
return request["content"]["channel"].ToString(); | |
} | |
catch (Exception e) { | |
return "none"; | |
} | |
}" /> | |
<set-variable name="IsTrial" value="@(context.User.Groups.Where(g => g.Name == "ApiTrial").Count() > 0)" /> | |
<rate-limit-by-key calls="2" renewal-period="10" | |
increment-condition="@(context.Variables.GetValueOrDefault("IsTrial", false))" | |
counter-key="@(String.Join("_", | |
context.Subscription.Id, | |
"ApiTrial", | |
context.Variables.GetValueOrDefault("IsTrial", false).ToString(), | |
(string) context.Variables["Channel"]))" /> | |
</inbound> | |
</policies> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment