Skip to content

Instantly share code, notes, and snippets.

@mattruma
Created Dec 15, 2021
Embed
What would you like to do?
<policies>
<inbound>
<base />
<set-backend-service backend-id="MarvelAPI" />
<set-variable name="ts" value="@(System.DateTime.Now.Subtract(new System.DateTime(1970, 1, 1)).TotalSeconds.ToString())" />
<set-variable name="hash" value="@{
var md5 = System.Security.Cryptography.MD5.Create();
var hashBytes = md5.ComputeHash(System.Text.Encoding.ASCII.GetBytes(System.Convert.ToString(context.Variables["ts"]) + "{{MarvelPrivateKey}}" + "{{MarvelPublicKey}}"));
var sb = new System.Text.StringBuilder();
for (int i = 0; i < hashBytes.Length; i++)
{
sb.Append(hashBytes[i].ToString("X2"));
}
return sb.ToString().ToLower();
}" />
<set-query-parameter name="ts" exists-action="override">
<value>@((string)context.Variables["ts"])</value>
</set-query-parameter>
<set-query-parameter name="hash" exists-action="override">
<value>@((string)context.Variables["hash"])</value>
</set-query-parameter>
<set-query-parameter name="apikey" exists-action="override">
<value>{{MarvelPublicKey}}</value>
</set-query-parameter>
</inbound>
<backend>
<base />
</backend>
<outbound>
<base />
</outbound>
<on-error>
<base />
</on-error>
</policies>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment