Created
July 31, 2013 18:04
-
-
Save brunomlopes/6124492 to your computer and use it in GitHub Desktop.
Overriding Glimpse's default resource so we can enable it in production and doesn't leak information when someone tries to access glimpse.axd
This file contains hidden or 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
| using System.Collections.Generic; | |
| using System.Linq; | |
| using System.Net; | |
| using Glimpse.Core.Extensibility; | |
| using Glimpse.Core.Framework; | |
| using Glimpse.Core.ResourceResult; | |
| namespace weListen.Infrastructure | |
| { | |
| public class GlimpseServiceLocator : IServiceLocator | |
| { | |
| public T GetInstance<T>() where T : class | |
| { | |
| #if !DEBUG | |
| if (typeof (T) == typeof (IResource)) | |
| { | |
| object defaultResource = new DefaultResource(); | |
| return (T) defaultResource; | |
| } | |
| #endif | |
| return null; | |
| } | |
| public ICollection<T> GetAllInstances<T>() where T : class | |
| { | |
| return null; | |
| } | |
| } | |
| public class DefaultResource : IResource | |
| { | |
| public IResourceResult Execute(IResourceContext context) | |
| { | |
| return new StatusCodeResourceResult((int) HttpStatusCode.OK, "Nah-ha!"); | |
| } | |
| public string Name | |
| { | |
| get { return "welisten-default"; } | |
| } | |
| public IEnumerable<ResourceParameterMetadata> Parameters | |
| { | |
| get { return Enumerable.Empty<ResourceParameterMetadata>(); } | |
| } | |
| } | |
| } |
This file contains hidden or 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
| <glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd" serviceLocatorType="weListen.Infrastructure.GlimpseServiceLocator, weListen"> | |
| <runtimePolicies> | |
| <ignoredTypes> | |
| <add type="Glimpse.AspNet.Policy.LocalPolicy, Glimpse.AspNet" /> | |
| <add type="Glimpse.Core.Policy.ControlCookiePolicy, Glimpse.Core" /> | |
| </ignoredTypes> | |
| </runtimePolicies> | |
| </glimpse> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment