Skip to content

Instantly share code, notes, and snippets.

@amitapl
Created August 24, 2012 07:02
Show Gist options
  • Save amitapl/3446947 to your computer and use it in GitHub Desktop.
Save amitapl/3446947 to your computer and use it in GitHub Desktop.
using Microsoft.WindowsAzure.MobileServices;
using System;
using Windows.Foundation;
namespace MobileServices
{
public class AdminServiceFilter : IServiceFilter
{
private bool disableScripts;
public AdminServiceFilter(bool disableScripts)
{
this.disableScripts = disableScripts;
}
public IAsyncOperation<IServiceFilterResponse> Handle(IServiceFilterRequest request, IServiceFilterContinuation continuation)
{
// Add master key to the request's header to have admin level control
request.Headers["X-ZUMO-MASTER"] = "Your Master Key Here";
if (this.disableScripts)
{
// Get the request's query and append noScript=true as the first query parameter
var uriBuilder = new UriBuilder(request.Uri);
var oldQuery = (uriBuilder.Query ?? string.Empty).Trim('?');
uriBuilder.Query = ("noScript=true&" + oldQuery).Trim('&');
request.Uri = uriBuilder.Uri;
}
return continuation.Handle(request);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment