Skip to content

Instantly share code, notes, and snippets.

@grumpydev
Last active December 11, 2015 02:18
Show Gist options
  • Save grumpydev/4529503 to your computer and use it in GitHub Desktop.
Save grumpydev/4529503 to your computer and use it in GitHub Desktop.
namespace NooVerbs
{
public class MyBadgerModule : NooModuleBase
{
public MyBadgerModule()
{
this.Badger["/"] = _ => "erm";
}
}
}
namespace NooVerbs
{
using System.Reflection;
using Nancy;
public class MyBootstrapper : DefaultNancyBootstrapper
{
protected override void ApplicationStartup(Nancy.TinyIoc.TinyIoCContainer container, Nancy.Bootstrapper.IPipelines pipelines)
{
base.ApplicationStartup(container, pipelines);
pipelines.BeforeRequest += ctx =>
{
if (ctx.Request.Method == "GET")
{
var prop = typeof(Request).GetProperty("Method", BindingFlags.Public | BindingFlags.Instance);
prop.SetValue(ctx.Request, "Badger", null);
}
return null;
};
}
}
}
namespace NooVerbs
{
using Nancy;
public abstract class NooModuleBase : NancyModule
{
protected NooModuleBase()
{
}
protected NooModuleBase(string modulePath)
: base(modulePath)
{
}
public RouteBuilder Badger
{
get { return new RouteBuilder("Badger", this); }
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment