Skip to content

Instantly share code, notes, and snippets.

@akimboyko
Forked from glennblock/app.csx
Created March 25, 2013 05:16
Show Gist options
  • Save akimboyko/5235074 to your computer and use it in GitHub Desktop.
Save akimboyko/5235074 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using Autofac;
using Nancy;
using Nancy.Bootstrapper;
using Nancy.Bootstrappers.Autofac;
using Nancy.Hosting.Self;
using Nancy.Routing;
public class Bootstrapper : AutofacNancyBootstrapper
{
protected override IEnumerable<ModuleRegistration> Modules
{
get
{
return new [] {
new ModuleRegistration(typeof(IndexModule), typeof(IndexModule).FullName)
};
}
}
protected override NancyInternalConfiguration InternalConfiguration
{
get
{
return NancyInternalConfiguration.WithOverrides(x => x.RouteDescriptionProvider = typeof(Foo));
}
}
}
public class IndexModule : NancyModule
{
public IndexModule()
{
Get["/"] = x => {
return "Nancy running on ScriptCS!";
};
}
}
public class Foo : IRouteDescriptionProvider
{
public string GetDescription(INancyModule module, string path)
{
return string.Empty;
}
}
NancyBootstrapperLocator.Bootstrapper = new Bootstrapper();
var nancyHost = new NancyHost(new Uri("http://localhost:1234/nancy/"));
nancyHost.Start();
Console.WriteLine("Nancy is running at ...");
Console.ReadKey();
nancyHost.Stop();
<packages>
<package id="Nancy" version="0.16.1" targetFramework="net40" />
<package id="Nancy.Hosting.Self" version="0.16.1" targetFramework="net40" />
<package id="Nancy.Bootstrappers.Autofac" version="0.16.1" targetFramework="net40" />
<package id="Autofac" version="2.6.3.862" targetFramework="net40" />
</packages>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment