Skip to content

Instantly share code, notes, and snippets.

@ioleksiy
Created March 5, 2012 11:33
Show Gist options
  • Select an option

  • Save ioleksiy/1977951 to your computer and use it in GitHub Desktop.

Select an option

Save ioleksiy/1977951 to your computer and use it in GitHub Desktop.
Using MvcMiniProfiler with NancyFX
public class CustomBootstrapper : DefaultNancyBootstrapper
{
protected override void ApplicationStartup(TinyIoCContainer container, IPipelines pipelines)
{
base.ApplicationStartup(container, pipelines);
pipelines.BeforeRequest += PreRequest;
pipelines.AfterRequest += PostRequest;
}
private static Response PreRequest(NancyContext ctx)
{
MiniProfiler.Start();
}
private static void PostRequest(NancyContext ctx)
{
MiniProfiler.Stop();
}
}
public class ExampleModule : NancyModule
{
public ExampleModule()
{
Get["/"] = IndexFunc;
}
private Response IndexFunc(dynamic param)
{
var profiler = MiniProfiler.Current;
using (profiler.Step("Indexing"))
{
// Some code here for index measure
}
}
}
@ioleksiy
Copy link
Author

ioleksiy commented Mar 5, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment