public void Start() { var opts = new NancyOptions(); var app = Owin.OwinAppModule.OfMidFunc("/", NancyMiddleware.UseNancy(opts)); Web.startWebServer(Web.defaultConfig, app); }
private static void Main(string[] args) { // Method 1: Using Microsoft.Owin.Hosting: Action <IAppBuilder> buildApp = app => app.Use((context, next) => { context.Response.StatusCode = 200; context.Response.ReasonPhrase = "OK"; context.Response.Write("Hello from WebListener!"); return(Task.FromResult(0)); }); var startOptions = new StartOptions("http://*****:*****@"OwinWebListener running via Microsoft.Owin.Hosting..."); Console.ReadLine(); } // Method 2: Using OwinWebListener directly (and with Nancy) using (var listener = new OwinWebListener()) { listener.Start(NancyMiddleware.UseNancy()(null), "http://*****:*****@"OwinWebListener running standalone..."); Console.ReadLine(); } }
public static int Main(string[] args) { var opts = new NancyOptions(); var app = Owin.OwinAppModule.OfMidFunc("/", NancyMiddleware.UseNancy(opts)); Web.startWebServer(Web.defaultConfig, app); return(0); }
/// <summary> /// Adds Nancy to the OWIN pipeline. /// </summary> /// <param name="builder">The application builder.</param> /// <param name="options">The Nancy options.</param> /// <returns>IAppBuilder.</returns> public static IAppBuilder UseNancy(this IAppBuilder builder, NancyOptions options = null) { var nancyOptions = options ?? new NancyOptions(); HookDisposal(builder, nancyOptions); return(builder.Use(NancyMiddleware.UseNancy(nancyOptions))); }
protected override Func <IDictionary <string, object>, Task> Init() { return(NancyMiddleware .UseNancy(opt => { opt.Bootstrapper = new LancyBootstrapper(); })(_ => Task.CompletedTask)); }
public static void Main() { var opts = new NancyOptions { Bootstrapper = new Bootstrap() }; var app = Suave.Owin.OwinAppModule.OfMidFunc("/", NancyMiddleware.UseNancy(opts)); Web.startWebServer(Web.defaultConfig, app); }
static void Main(string[] args) { var myNancyAppFunc = NancyMiddleware.UseNancy()(NancyOptions options => { // Modify Nancy options if desired; return(Task.FromResult(0)); }); using (var server = ServerBuilder.New() .SetOwinApp(myNancyAppFunc) .SetEndPoint(new IPEndPoint(IPAddress.Any, 8080)) .SetCertificate(new X509Certificate2("certificate.pfx", "password")) .Build() ) { server.Start(); Console.WriteLine("Running on 8080"); Console.ReadLine(); } }
public NancyMiddlewareFixture() { this.fakeEngine = A.Fake <INancyEngine>(); this.fakeBootstrapper = A.Fake <INancyBootstrapper>(); A.CallTo(() => this.fakeBootstrapper.GetEngine()).Returns(this.fakeEngine); this.host = NancyMiddleware.UseNancy(new NancyOptions { Bootstrapper = this.fakeBootstrapper })(null); this.environment = new Dictionary <string, object> { { "owin.RequestMethod", "GET" }, { "owin.RequestPath", "/test" }, { "owin.RequestPathBase", "/root" }, { "owin.RequestQueryString", "var=value" }, { "owin.RequestBody", Stream.Null }, { "owin.RequestHeaders", new Dictionary <string, string[]>(StringComparer.OrdinalIgnoreCase) }, { "owin.RequestScheme", "http" }, { "owin.ResponseHeaders", new Dictionary <string, string[]>(StringComparer.OrdinalIgnoreCase) }, { "owin.ResponseBody", new MemoryStream() }, { "owin.ResponseReasonPhrase", string.Empty }, { "owin.Version", "1.0" }, { "owin.CallCancelled", CancellationToken.None } }; }