nancy

Getting CORS To Work With Nancy

大兔子大兔子 提交于 2019-12-01 01:05:21
问题 I am trying to get all types of requests to work with Nancy and CORS. Currently I add a pipeline at the end of the request: pipelines.AfterRequest.AddItemToEndOfPipeline((ctx) => ctx.Response .WithHeader("Access-Control-Allow-Origin", "http://localhost:57515") .WithHeader("Access-Control-Allow-Methods", "POST, GET, DELETE, PUT, OPTIONS") .WithHeader("Access-Control-Allow-Headers", "Accept, Origin, Content-type") .WithHeader("Allow", "POST, GET, DELETE, PUT, OPTIONS")) The options request

NancyFX: Routes with query string parameters always returns a 404 NotFound

こ雲淡風輕ζ 提交于 2019-11-30 18:19:34
I have a simple Nancy module. I want to pass in query string (q-s) parameters to the handler. If I do not have any q-s params everything is fine. As soon as I add a param then I get a 404 status code returned. NancyModule public class SimpleModule : NancyModule { public SimpleModule() { Get["/"] = parameters => HttpStatusCode.OK; } } Unit Test - Passes [Fact] public void SimpleModule__Should_return_statusOK_when_passing_query_params() { const string uri = "/"; var response = Fake.Browser().Get(uri, with => with.HttpRequest()); response.StatusCode.ShouldBe(HttpStatusCode.OK); } Unit Test -

Why are no query parameters being passed to my NancyFX module?

天涯浪子 提交于 2019-11-30 17:57:32
I am running a self-hosted NancyFX web server inside of my application. Right now I have one module hosted: public class MetricsModule : NancyModule { private IStorageEngine _storageEngine; public MetricsModule(IStorageEngine storageEngine) : base("/metrics") { _storageEngine = storageEngine; Get["/list"] = parameters => { var metrics = _storageEngine.GetKnownMetrics(); return Response.AsJson(metrics.ToArray()); }; Get["/query"] = parameters => { var rawStart = parameters.start; var rawEnd = parameters.end; var metrics = parameters.metrics; return Response.AsJson(0); }; } } My Bootstrapper

Configure NancyFx with Fluent Validation

假装没事ソ 提交于 2019-11-30 13:08:41
Is there any configuration code that I have to add in the application Bootstrapper to enable FluentValidation in Nancy? Following the example from https://github.com/NancyFx/Nancy/tree/master/src/Nancy.Demo.Validation I receive the following exception message when trying to use this.Validate on model: No model validator factory could be located . I'm using Nancy version 0.11.0.0 TheCodeJunkie Are you using one of the Bootstrapper packages (autofac, ninject, unity, windsor, structuremap)? If you are then you need to inherit from the bootstrapper type, override ConfigureApplicationContainer and

SignalR plus NancyFX : A simple but well worked example

非 Y 不嫁゛ 提交于 2019-11-30 04:46:17
There are a few examples of NancyFX being integrated with SignalR, for example Signalr & Nancyfx integration Since I am just starting out I want a simple, well worked canonical example that I can work from. A nancy version of the chat example from Microsoft would do fine. Tutorial: Getting Started with SignalR (C#) Thanks I am going to answer my own question. I put together a little canonical-chat example based on the Microsoft walkthrough. You can get it from GitHub: Nancy + SignalR - Canonical Chat Update This example has been updated to use the latest SignalR and NancyFX Assemblies as of

Configuring JsonNetSerializer and JsonNetBodyDeserializer using Nancy TinyIoC

妖精的绣舞 提交于 2019-11-30 03:38:52
问题 I am a noob to Nancy. I have been using it as a framework to produce a REST API. I am familiar with Json.NET so I've been playing with the Nancy.Serialization.JsonNet package. My goal: to customize the behavior (i.e. change the settings) of the JsonNetSerializer and JsonNetBodyDeserializer . Specifically I'd like to incorporate the following settings... var settings = new JsonSerializerSettings { Formatting = Formatting.Indented }; settings.Converters.Add( new StringEnumConverter {

NancyFX: Routes with query string parameters always returns a 404 NotFound

痴心易碎 提交于 2019-11-30 02:32:40
问题 I have a simple Nancy module. I want to pass in query string (q-s) parameters to the handler. If I do not have any q-s params everything is fine. As soon as I add a param then I get a 404 status code returned. NancyModule public class SimpleModule : NancyModule { public SimpleModule() { Get["/"] = parameters => HttpStatusCode.OK; } } Unit Test - Passes [Fact] public void SimpleModule__Should_return_statusOK_when_passing_query_params() { const string uri = "/"; var response = Fake.Browser()

NancyFx and Windows Authentication

陌路散爱 提交于 2019-11-29 20:30:24
I want to use NancyFx for an intranet web app. All the documentation and forums only mention Forms and Basic authentication. Anyone successfully use Nancy with Windows Authentication? There's also something called Nancy.Authentication.Stateless but I can't see what that does (looks like it's for use in Apis). I used this in an internal project recently - I don't really like it, and it ties you to asp.net hosting, but it did the job: namespace Blah.App.Security { using System; using System.Collections.Generic; using System.Linq; using System.Security.Principal; using System.Web; using Nancy;

Is it possible to enable CORS using NancyFX?

早过忘川 提交于 2019-11-29 20:19:22
I have an API service made with NancyFX, and a couple of front-end developers creating an SPA JS client against this API. We would like to test the client side code against the published server without having to publish the client code with too much frequency. But, the client runs at localhost, and the server is at Windows Azure. Is it possible and easy to enable CORS on the NancyFX server? How can I do that? Thanks. oaamados Its possible to do this in the bootstraper of Nancy protected override void RequestStartup(TinyIoCContainer container, IPipelines pipelines, NancyContext context) { /

Configure NancyFx with Fluent Validation

混江龙づ霸主 提交于 2019-11-29 18:17:38
问题 Is there any configuration code that I have to add in the application Bootstrapper to enable FluentValidation in Nancy? Following the example from https://github.com/NancyFx/Nancy/tree/master/src/Nancy.Demo.Validation I receive the following exception message when trying to use this.Validate on model: No model validator factory could be located . I'm using Nancy version 0.11.0.0 回答1: Are you using one of the Bootstrapper packages (autofac, ninject, unity, windsor, structuremap)? If you are