Skip to content

Instantly share code, notes, and snippets.

@bitsprint
Created July 29, 2018 13:24
Show Gist options
  • Save bitsprint/6f0a3008a655d83ac0630a91dd9523ce to your computer and use it in GitHub Desktop.
Save bitsprint/6f0a3008a655d83ac0630a91dd9523ce to your computer and use it in GitHub Desktop.
Nancy in Linqpad - simple script to get a quick endpoint up and running
<Query Kind="Program">
<NuGetReference>Nancy.Hosting.Self</NuGetReference>
<Namespace>Nancy</Namespace>
<Namespace>Nancy.Bootstrapper</Namespace>
<Namespace>Nancy.Conventions</Namespace>
<Namespace>Nancy.Cookies</Namespace>
<Namespace>Nancy.Cryptography</Namespace>
<Namespace>Nancy.Culture</Namespace>
<Namespace>Nancy.Diagnostics</Namespace>
<Namespace>Nancy.Diagnostics.Modules</Namespace>
<Namespace>Nancy.ErrorHandling</Namespace>
<Namespace>Nancy.Extensions</Namespace>
<Namespace>Nancy.Helpers</Namespace>
<Namespace>Nancy.Hosting.Self</Namespace>
<Namespace>Nancy.IO</Namespace>
<Namespace>Nancy.Json</Namespace>
<Namespace>Nancy.Json.Converters</Namespace>
<Namespace>Nancy.Localization</Namespace>
<Namespace>Nancy.ModelBinding</Namespace>
<Namespace>Nancy.ModelBinding.DefaultBodyDeserializers</Namespace>
<Namespace>Nancy.ModelBinding.DefaultConverters</Namespace>
<Namespace>Nancy.Owin</Namespace>
<Namespace>Nancy.Responses</Namespace>
<Namespace>Nancy.Responses.Negotiation</Namespace>
<Namespace>Nancy.Routing</Namespace>
<Namespace>Nancy.Routing.Constraints</Namespace>
<Namespace>Nancy.Routing.Trie</Namespace>
<Namespace>Nancy.Routing.Trie.Nodes</Namespace>
<Namespace>Nancy.Security</Namespace>
<Namespace>Nancy.Session</Namespace>
<Namespace>Nancy.TinyIoc</Namespace>
<Namespace>Nancy.Validation</Namespace>
<Namespace>Nancy.Validation.Rules</Namespace>
<Namespace>Nancy.ViewEngines</Namespace>
<Namespace>Nancy.ViewEngines.Razor</Namespace>
<Namespace>Nancy.ViewEngines.SuperSimpleViewEngine</Namespace>
<Namespace>Nancy.Xml</Namespace>
<Namespace>System.Reflection</Namespace>
</Query>
void Main()
{
using (var host = new Nancy.Hosting.Self.NancyHost(
new Uri("http://localhost:8080"),
new LinqpadNancyBootstrapper(),
new HostConfiguration { UrlReservations = new UrlReservations { CreateAutomatically = true } }))
{
host.Start();
Console.ReadLine();
}
}
public class HelloModule : Nancy.NancyModule
{
public HelloModule() : base("api")
{
Get["/"] = parameters => "Hello World";
Post["/"] = parameters => { Context.Request.Body.AsString().Dump(); return HttpStatusCode.OK; };
}
}
public class LinqpadNancyBootstrapper : Nancy.DefaultNancyBootstrapper
{
protected override void ConfigureApplicationContainer(Nancy.TinyIoc.TinyIoCContainer container)
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment