Skip to content

Instantly share code, notes, and snippets.

@masaeedu
Created October 7, 2016 21:50
Show Gist options
  • Save masaeedu/dbce7e75d7c0a1967f79fe156ef3ca94 to your computer and use it in GitHub Desktop.
Save masaeedu/dbce7e75d7c0a1967f79fe156ef3ca94 to your computer and use it in GitHub Desktop.
.NET Core starter with NancyFX
using System.IO;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Nancy;
using Nancy.Conventions;
using Nancy.Owin;
namespace ConsoleApplication
{
public class Program
{
public static void Main(string[] args)
{
var host = new WebHostBuilder()
.UseContentRoot(Directory.GetCurrentDirectory())
.UseKestrel()
.UseStartup<Startup>()
.Build();
host.Run();
}
}
public class Startup
{
public void Configure(IApplicationBuilder app)
{
app.UseOwin(x => x.UseNancy());
}
}
public class HomeModule : NancyModule
{
public HomeModule()
{
Get("/", p => Response.AsFile("public/index.html", "text/html"));
}
}
public class CustomBoostrapper : DefaultNancyBootstrapper
{
protected override void ConfigureConventions(NancyConventions conventions)
{
base.ConfigureConventions(conventions);
conventions.StaticContentsConventions.Add(
StaticContentConventionBuilder.AddDirectory("/", "public")
);
}
}
}
{
"version": "1.0.0-*",
"buildOptions": {
"debugType": "portable",
"emitEntryPoint": true,
"copyToOutput": {
"include": "./public"
}
},
"dependencies": {
"Nancy": "2.0.0-barneyrubble",
"Microsoft.AspNetCore.Server.Kestrel": "1.0.0",
"Microsoft.AspNetCore.Owin": "1.0.0"
},
"tools": {
"Microsoft.DotNet.Watcher.Tools": "1.0.0-preview2-final"
},
"frameworks": {
"netcoreapp1.0": {
"dependencies": {
"Microsoft.NETCore.App": {
"type": "platform",
"version": "1.0.1"
}
},
"imports": "dnxcore50"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment