Giter VIP home page Giter VIP logo

nancyfx / nancy Goto Github PK

View Code? Open in Web Editor NEW
7.2K 432.0 1.5K 44.4 MB

Lightweight, low-ceremony, framework for building HTTP based services on .Net and Mono

Home Page: http://nancyfx.org

License: MIT License

C# 95.46% JavaScript 1.62% HTML 1.71% CSS 0.15% Liquid 0.47% PowerShell 0.08% Shell 0.06% XSLT 0.42% Smalltalk 0.04% Visual Basic .NET 0.01%
nancy c-sharp nancy-application mono web web-application-framework framework dotnet dotnet-core mit nancyfx

nancy's Introduction

** Announcement ** - Nancy is no longer being maintained!

We would like to thank all the thousands of users of Nancy, all the people who wrote blog posts, conference speakers, video producers and those that spread the word of Nancy.

We would like to thank the 150+ contributors to Nancy that made it what it became, without you the work would have been much harder and opportunities missed.

We would like to thank VQ for financially sponsoring our open source efforts.

We would like to thank the core contributors to Nancy @jchannon, @khellang, @damianh, @phillip-haydon, @prabirshrestha, @horsdal for working hard into the nights coding, testing and writing docs but most importantly the founders of Nancy itself @thecodejunkie and @grumpydev whose vision made Nancy what it was, a fun, performant and enjoyable web framework.

Support

We understand that organisations may have services and products that still depend on Nancy in production. A couple of members of the team can offer a support, maintenance, migration services on commercial terms. Please reach out to [email protected] to discuss options.

Forking

Nancy's licence is permissible so we encourage forking if you need to perform maintenance. However, the logos and name are copyright to Andreas Håkansson and Steven Robbins and are not for re-use or editing. Please see full licence information here


Meet Nancy NuGet Version Slack Status

Nancy is a lightweight, low-ceremony, framework for building HTTP based services on .NET Framework/Core and Mono. The goal of the framework is to stay out of the way as much as possible and provide a super-duper-happy-path to all interactions.

Nancy is designed to handle DELETE, GET, HEAD, OPTIONS, POST, PUT and PATCH requests and provides a simple, elegant, Domain Specific Language (DSL) for returning a response with just a couple of keystrokes, leaving you with more time to focus on the important bits.. your code and your application.

Write your application

public class Module : NancyModule
{
    public Module()
    {
        Get("/greet/{name}", x => {
            return string.Concat("Hello ", x.name);
        });
    }
}

Compile, run and enjoy the simple, elegant design!

Features

  • Built from the bottom up, not simply a DSL on top of an existing framework. Removing limitations and feature hacks of an underlying framework, as well as the need to reference more assemblies than you need. keep it light
  • Run anywhere. Nancy is not built on any specific hosting technology can be run anywhere. Out of the box, Nancy supports running on ASP.NET/IIS, WCF, Self-hosting and any OWIN
  • Ultra lightweight action declarations for GET, HEAD, PUT, POST, DELETE, OPTIONS and PATCH requests
  • View engine integration (Razor, Spark, dotLiquid, our own SuperSimpleViewEngine and many more)
  • Powerful request path matching that includes advanced parameter capabilities. The path matching strategy can be replaced with custom implementations to fit your exact needs
  • Easy response syntax, enabling you to return things like int, string, HttpStatusCode and Action elements without having to explicitly cast or wrap your response - you just return it and Nancy will do the work for you
  • A powerful, light-weight, testing framework to help you verify the behavior of your application
  • Content negotiation
  • And much, much more

The super-duper-happy-path

The "super-duper-happy-path" (or SDHP if you’re ‘down with the kids’ ;-)) is a phrase we coined to describe the ethos of Nancy; and providing the “super-duper-happy-path” experience is something we strive for in all of our APIs.

While it’s hard to pin down exactly what it is, it’s a very emotive term after all, but the basic ideas behind it are:

  • “It just works” - you should be able to pick things up and use them without any mucking about. Added a new module? That’s automatically discovered for you. Brought in a new View Engine? All wired up and ready to go without you having to do anything else. Even if you add a new dependency to your module, by default we’ll locate that and inject it for you - no configuration required.
  • “Easily customisable” - even though “it just works”, there shouldn’t be any barriers that get in the way of customisation should you want to work the way you want to work with the components that you want to use. Want to use another container? No problem! Want to tweak the way routes are selected? Go ahead! Through our bootstrapper approach all of these things should be a piece of cake.
  • “Low ceremony” - the amount of “Nancy code” you should need in your application should be minimal. The important part of any Nancy application is your code - our code should get out of your way and let you get on with building awesome applications. As a testament to this it’s actually possible to fit a functional Nancy application into a single Tweet :-)
  • “Low friction” - when building software with Nancy the APIs should help you get where you want to go, rather than getting in your way. Naming should be obvious, required configuration should be minimal, but power and extensibility should still be there when you need it.

Above all, creating an application with Nancy should be a pleasure, and hopefully fun! But without sacrificing the power or extensibility that you may need as your application grows.

Getting started

As a start several working samples are provided in the /sample directory. Simply run the build script build.ps1 (for Windows PowerShell) or build.sh (for *nix-Bash) first.

Community

Nancy followers can be found on Slack NancyFx team. You can also find Nancy on Twitter using the #NancyFx hashtag.

Help out

There are many ways you can contribute to Nancy. Like most open-source software projects, contributing code is just one of many outlets where you can help improve. Some of the things that you could help out with in Nancy are:

  • Documentation (both code and features)
  • Bug reports
  • Bug fixes
  • Feature requests
  • Feature implementations
  • Test coverage
  • Code quality
  • Sample applications

Continuous integration builds

Platform Status
AppVeyor (.NET & .NET Core) Build Status
Travis (Mono) Build Status

To get build artifacts of latest master, please use our MyGet feed

Contributors

Nancy is not a one man project and many of the features that are available would not have been possible without the awesome contributions from the community!

For a full list of contributors, please see the website.

Code of Conduct

This project has adopted the code of conduct defined by the Contributor Covenant to clarify expected behavior in our community. For more information see the .NET Foundation Code of Conduct.

Contribution License Agreement

Contributing to Nancy requires you to sign a contribution license agreement (CLA) for anything other than a trivial change. By signing the contribution license agreement, the community is free to use your contribution to .NET Foundation projects.

.NET Foundation

This project is supported by the .NET Foundation.

Copyright

Copyright © 2010 Andreas Håkansson, Steven Robbins and contributors

License

Nancy is licensed under MIT. Refer to license.txt for more information.

nancy's People

Contributors

06b avatar andypike avatar asbjornu avatar blairconrad avatar cemremengu avatar codeprogression avatar damianh avatar daveaglick avatar graemef avatar grumpydev avatar horsdal avatar jasonmead avatar jchannon avatar jrsconfitto avatar khellang avatar liddellj avatar logicbomb avatar marcusoftnet avatar mmozuras avatar nico-francois avatar phillip-haydon avatar prabirshrestha avatar richardprice avatar robertthegrey avatar simoncropp avatar sloncho avatar thecodejunkie avatar thefringeninja avatar tpluscode avatar xt0rted avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nancy's Issues

Route Resolution bug

I think this had been fixed earlier but was recently broken again. The following routes:

Get["/hello"] = x => { return "Is There Anybody In There?"; };
Get["/{name}"] = x => { return "Hi " + x.name; };

are resolving "Hi hello" when you access /hello instead of resolving the first route. This creates some problem when defining static routes. In my mind the priority should be:

  1. Completely static route (i.e. exact match to any route without parameters)
  2. Route with the most parameter captures
  3. Route matched by Regex

I'll write a patch for this today.

bug in views template location detection on linux box

On linux if passing ~/views/template.cshtml and the template.cshtml is stored in /Views Nancy view engine unable to located the view template notice (/views != ~/Views)

Suggest, Nancy views template location should be detect views base on convention (~/Views | ~/views) or allow best to allow user to define views template location in web.config no need to recompile the application if the moving platform or if user decided to place template file elsewhere.

Mono Improvements

  • Removal of Mono solution, replaced with a build configuration
  • Make sure all core functionality works on Mono
  • Verify all tests work on Mono
  • Add CI support for Mono to prevent regression

Cannot compile spark views due to no escaping

Using the default conventions I have a Module path of /dashboard, and a view path of Views\Dashboard. The below exception occurs (Nancy 0.6.0).

It looks like the namespace should be escaped (convert \ to _?) but also the TargetNamespace value on the SparkViewAttribute needs to be escaped.

[BatchCompilerException: Dynamic view compilation failed.
c:\Windows\Temp\s0yy2wnc.0.cs(2,16): error CS1056: Unexpected character ''
c:\Windows\Temp\s0yy2wnc.0.cs(6,32): error CS1009: Unrecognized escape sequence
c:\Windows\Temp\s0yy2wnc.0.cs(2,16): error CS1514: { expected

1
2 namespace Views\Dashboard
3 {
4
5 [global::Spark.SparkViewAttribute(
6 TargetNamespace="Views\Dashboard",
7 Templates = new string[] {
8 "Views\Dashboard\DashboardIndex.spark"
9 })]
10 public class Viewf5461cd61c664709aaca67331b658e1f : Nancy.ViewEngines.Spark.NancySparkView
11 {
12
13 [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
14 private static System.Guid _generatedViewId = new System.Guid("f5461cd61c664709aaca67331b658e1f");
15 public override System.Guid GeneratedViewId
16 { get { return _generatedViewId; } }
17
18 [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
19 private void RenderViewLevel0()
20 {
21 #line hidden
22 Output.Write("\r\n\r\n\r\n\r\n <title>gsdgd</title>\r\n\r\n\r\n

\r\n Dashboard\r\n
\r\n\r\n\r\n");
23 #line default
24 }
25
26 [System.ComponentModel.EditorBrowsable(System.ComponentModel.EditorBrowsableState.Never)]
27 public override void Render()
28 {
29 RenderViewLevel0();
30 }
31 }
32 }

TinyIOC generates an exception (probably while booting the app)

Over at http://nerdbeers.apphb.com , I sometimes get the following exception (after it has been a while I visited):

Server Error in '/' Application.
Collection was modified; enumeration operation may not execute.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidOperationException: Collection was modified; enumeration operation may not execute.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace: 

[InvalidOperationException: Collection was modified; enumeration operation may not execute.]
   System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) +52
   System.Collections.Generic.Enumerator.MoveNext() +9644997
   System.Linq.WhereEnumerableIterator`1.MoveNext() +154
   System.Linq.d__71`1.MoveNext() +207
   System.Linq.d__71`1.MoveNext() +378
   System.Linq.WhereEnumerableIterator`1.MoveNext() +154
   TinyIoC.d__3b.MoveNext() in C:\Projecten\Org.NerdBeers\Dependencies\Nancy\src\Nancy\TinyIoc\TinyIoC.cs:3097
   System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +177
   TinyIoC.d__4`1.MoveNext() in C:\Projecten\Org.NerdBeers\Dependencies\Nancy\src\Nancy\TinyIoc\TinyIoC.cs:1861
   Nancy.Routing.RouteCache.BuildCache(IEnumerable`1 modules) in C:\Projecten\Org.NerdBeers\Dependencies\Nancy\src\Nancy\Routing\RouteCache.cs:21
   Nancy.Routing.RouteCache..ctor(INancyModuleCatalog moduleCatalog, IModuleKeyGenerator moduleKeyGenerator, INancyContextFactory contextFactory) in C:\Projecten\Org.NerdBeers\Dependencies\Nancy\src\Nancy\Routing\RouteCache.cs:16

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeMethodHandle._InvokeConstructor(IRuntimeMethodInfo method, Object[] args, SignatureStruct& signature, RuntimeType declaringType) +0
   System.RuntimeMethodHandle.InvokeConstructor(IRuntimeMethodInfo method, Object[] args, SignatureStruct signature, RuntimeType declaringType) +15
   System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +281
   System.Reflection.ConstructorInfo.Invoke(Object[] parameters) +17
   TinyIoC.TinyIoCContainer.ConstructType(Type type, ConstructorInfo constructor, NamedParameterOverloads parameters, ResolveOptions options) in C:\Projecten\Org.NerdBeers\Dependencies\Nancy\src\Nancy\TinyIoc\TinyIoC.cs:3050

[TinyIoCResolutionException: Unable to resolve type: Nancy.Routing.RouteCache]
   TinyIoC.TinyIoCContainer.ConstructType(Type type, ConstructorInfo constructor, NamedParameterOverloads parameters, ResolveOptions options) in C:\Projecten\Org.NerdBeers\Dependencies\Nancy\src\Nancy\TinyIoc\TinyIoC.cs:3054
   TinyIoC.TinyIoCContainer.ConstructType(Type type, ConstructorInfo constructor, ResolveOptions options) in C:\Projecten\Org.NerdBeers\Dependencies\Nancy\src\Nancy\TinyIoc\TinyIoC.cs:3022
   TinyIoC.SingletonFactory`2.GetObject(TinyIoCContainer container, NamedParameterOverloads parameters, ResolveOptions options) in C:\Projecten\Org.NerdBeers\Dependencies\Nancy\src\Nancy\TinyIoc\TinyIoC.cs:2345
   TinyIoC.TinyIoCContainer.ResolveInternal(TypeRegistration registration, NamedParameterOverloads parameters, ResolveOptions options) in C:\Projecten\Org.NerdBeers\Dependencies\Nancy\src\Nancy\TinyIoc\TinyIoC.cs:2822

[TinyIoCResolutionException: Unable to resolve type: Nancy.Routing.IRouteCache]
   TinyIoC.TinyIoCContainer.ResolveInternal(TypeRegistration registration, NamedParameterOverloads parameters, ResolveOptions options) in C:\Projecten\Org.NerdBeers\Dependencies\Nancy\src\Nancy\TinyIoc\TinyIoC.cs:2826
   TinyIoC.TinyIoCContainer.ConstructType(Type type, ConstructorInfo constructor, NamedParameterOverloads parameters, ResolveOptions options) in C:\Projecten\Org.NerdBeers\Dependencies\Nancy\src\Nancy\TinyIoc\TinyIoC.cs:3045
   TinyIoC.TinyIoCContainer.ConstructType(Type type, ConstructorInfo constructor, ResolveOptions options) in C:\Projecten\Org.NerdBeers\Dependencies\Nancy\src\Nancy\TinyIoc\TinyIoC.cs:3022
   TinyIoC.SingletonFactory`2.GetObject(TinyIoCContainer container, NamedParameterOverloads parameters, ResolveOptions options) in C:\Projecten\Org.NerdBeers\Dependencies\Nancy\src\Nancy\TinyIoc\TinyIoC.cs:2345
   TinyIoC.TinyIoCContainer.ResolveInternal(TypeRegistration registration, NamedParameterOverloads parameters, ResolveOptions options) in C:\Projecten\Org.NerdBeers\Dependencies\Nancy\src\Nancy\TinyIoc\TinyIoC.cs:2822

[TinyIoCResolutionException: Unable to resolve type: Nancy.INancyEngine]
   TinyIoC.TinyIoCContainer.ResolveInternal(TypeRegistration registration, NamedParameterOverloads parameters, ResolveOptions options) in C:\Projecten\Org.NerdBeers\Dependencies\Nancy\src\Nancy\TinyIoc\TinyIoC.cs:2826
   TinyIoC.TinyIoCContainer.Resolve(Type resolveType) in C:\Projecten\Org.NerdBeers\Dependencies\Nancy\src\Nancy\TinyIoc\TinyIoC.cs:991
   TinyIoC.TinyIoCContainer.Resolve() in C:\Projecten\Org.NerdBeers\Dependencies\Nancy\src\Nancy\TinyIoc\TinyIoC.cs:1110
   Nancy.DefaultNancyBootstrapper.GetEngineInternal() in C:\Projecten\Org.NerdBeers\Dependencies\Nancy\src\Nancy\DefaultNancyBootstrapper.cs:31
   Nancy.Bootstrapper.NancyBootstrapperBase`1.GetEngine() in C:\Projecten\Org.NerdBeers\Dependencies\Nancy\src\Nancy\Bootstrapper\NancyBootstrapperBase.cs:164
   Nancy.Hosting.Aspnet.NancyHttpRequestHandler..ctor() in C:\Projecten\Org.NerdBeers\Dependencies\Nancy\src\Nancy.Hosting.Aspnet\NancyHttpRequestHandler.cs:24

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache) +98
   System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) +241
   System.Activator.CreateInstance(Type type, Boolean nonPublic) +69
   System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +1136
   System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +111
   System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture) +23
   System.Web.HttpRuntime.CreateNonPublicInstance(Type type, Object[] args) +60
   System.Web.Configuration.HandlerFactoryCache..ctor(String type) +46
   System.Web.HttpApplication.GetFactory(String type) +81
   System.Web.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +223
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& 

I think it might be a problem with the initialisation of the container (I am using the default container, and my modules do not have any dependencies; code over at http://github.com/tojans/nerdbeers )

JsonResponse is limited to the max size of the StringBuilder

Seems this should be using Streams as is suggested by the choice of Action for the response content, but instead it uses a SB in a couple of places. First in the JsonResponse and then again in the JsonSerializer implementation.

I have to ask, why not simply use Newtonsoft? I know it introduces a dependency, is Netwonsoft not Mono compatible perhaps?

Browser not using the Form Values in request

The Browser doesn't use the FormValues as the bodycontents in the generated request

var response = browser.Post("/login/", (with) =>
            {
                with.HttpRequest();
                with.FormValue("Username", "username");
                with.FormValue("Password", "wrongpassword");
            });

The existing LoginFixture.Should_redirect_to_login_with_error_querystring_if_username_or_password_incorrect test is passing, but the form values defined in the setup aren't what are being Validated.

Build fails on x86

When building on x86 the Django test fail due to a missing Fsharp.Core ref.
Screendump :

CopyFilesToOutputDirectory:
  Copying file from "obj\Release\Nancy.Demo.Hosting.Aspnet.dll" to "bin\Nancy.Demo.Hosting.Aspnet.dll".
  Nancy.Demo.Hosting.Aspnet -> c:\Projecten\Nancy\src\Nancy.Demo.Hosting.Aspnet\bin\Nancy.Demo.Hosting.Aspnet.dll
  Copying file from "obj\Release\Nancy.Demo.Hosting.Aspnet.pdb" to "bin\Nancy.Demo.Hosting.Aspnet.pdb".
Done Building Project "c:\Projecten\Nancy\src\Nancy.Demo.Hosting.Aspnet\Nancy.Demo.Hosting.Aspnet.csproj" (default targ
ets).

Done Building Project "c:\Projecten\Nancy\src\Nancy.sln" (Clean;Build target(s)).


Build succeeded.

"c:\Projecten\Nancy\src\Nancy.sln" (Clean;Build target) (1) ->
"c:\Projecten\Nancy\src\Nancy.ViewEngines.Razor.Tests\Nancy.ViewEngines.Razor.Tests.csproj" (default target) (29:2) ->
(ResolveAssemblyReferences target) ->
  c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3245: Could not resolve th
is reference. Could not locate the assembly "FakeItEasy, Version=1.5.3971.200, Culture=neutral, PublicKeyToken=eff28e21
46d5fd2c, processorArchitecture=MSIL". Check to make sure the assembly exists on disk. If this reference is required by
 your code, you may get compilation errors. [c:\Projecten\Nancy\src\Nancy.ViewEngines.Razor.Tests\Nancy.ViewEngines.Raz
or.Tests.csproj]


"c:\Projecten\Nancy\src\Nancy.sln" (Clean;Build target) (1) ->
"c:\Projecten\Nancy\src\Nancy.ViewEngines.NDjango\Nancy.ViewEngines.NDjango.csproj" (default target) (6:4) ->
  c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(1360,9): warning MSB3245: Could not resolve th
is reference. Could not locate the assembly "FSharp.Core". Check to make sure the assembly exists on disk. If this refe
rence is required by your code, you may get compilation errors. [c:\Projecten\Nancy\src\Nancy.ViewEngines.NDjango\Nancy
.ViewEngines.NDjango.csproj]

    2 Warning(s)
    0 Error(s)

Time Elapsed 00:01:01.82
D, [2011-03-18T10:23:50.125000 #2352] DEBUG -- : Executing MSpec: "c:/Projecten/Nancy/tools/mspec/mspec.exe" "src/Nancy.
Tests/bin/Release/Nancy.Tests.dll"

Specs in Nancy.Tests:

Handling a HEAD request, when head request matched existing route
» should set status code to ok
» should set content type to text html
» should set blank content

Handling a HEAD request, when head request does not matched existing route
» should set status code to not found
» should set content type to text html
» should set blank content

Handling a DELETE request, when delete request matched existing route
» should set status code to ok
» should set content type to text html
» should set content

Handling a DELETE request, when delete request does not matched existing route
» should set status code to not found
» should set content type to text html
» should set blank content

Handling a GET request, when get request matched existing route
» should set status code to ok
» should set content type to text html
» should set content

Handling a GET request with parameters, when get request matched existing route with parameters
» should set status code to ok
» should set content type to text html
» should set content

Handling a GET request, when get request does not matched existing route
» should set status code to not found
» should set content type to text html
» should set blank content

Handling a POST request, when post request matched existing route
» should set status code to ok
» should set content type to text html
» should set content

Handling a POST request, when post request does not matched existing route
» should set status code to not found
» should set content type to text html
» should set blank content

Handling a PUT request, when put request matched existing route
» should set status code to ok
» should set content type to text html
» should set content

Handling a PUT request, when put request does not matched existing route
» should set status code to not found
» should set content type to text html
» should set blank content

Contexts: 11, Specifications: 33, Time: 10.31 seconds
D, [2011-03-18T10:24:01.843000 #2352] DEBUG -- : Executing XUnit: "c:/Projecten/Nancy/tools/xunit/xunit.console.clr4.x86
.exe" src/Nancy.Authentication.Forms.Tests/bin/Release/Nancy.Authentication.Forms.Tests.dll
xUnit.net console test runner (32-bit .NET 4.0.30319.1)
Copyright (C) 2007-10 Microsoft Corporation.

xunit.dll:     Version 1.7.0.1540
Test assembly: c:\Projecten\Nancy\src\Nancy.Authentication.Forms.Tests\bin\Release\Nancy.Authentication.Forms.Tests.dll

28 total, 0 failed, 0 skipped, took 8.892 seconds
D, [2011-03-18T10:24:15.171000 #2352] DEBUG -- : Executing XUnit: "c:/Projecten/Nancy/tools/xunit/xunit.console.clr4.x86
.exe" src/Nancy.BootStrappers.Ninject.Tests/bin/Release/Nancy.BootStrappers.Ninject.Tests.dll
xUnit.net console test runner (32-bit .NET 4.0.30319.1)
Copyright (C) 2007-10 Microsoft Corporation.

xunit.dll:     Version 1.7.0.1540
Test assembly: c:\Projecten\Nancy\src\Nancy.BootStrappers.Ninject.Tests\bin\Release\Nancy.BootStrappers.Ninject.Tests.dl
l

9 total, 0 failed, 0 skipped, took 4.901 seconds
D, [2011-03-18T10:24:22.234000 #2352] DEBUG -- : Executing XUnit: "c:/Projecten/Nancy/tools/xunit/xunit.console.clr4.x86
.exe" src/Nancy.BootStrappers.StructureMap.Tests/bin/Release/Nancy.BootStrappers.StructureMap.Tests.dll
xUnit.net console test runner (32-bit .NET 4.0.30319.1)
Copyright (C) 2007-10 Microsoft Corporation.

xunit.dll:     Version 1.7.0.1540
Test assembly: c:\Projecten\Nancy\src\Nancy.BootStrappers.StructureMap.Tests\bin\Release\Nancy.BootStrappers.StructureMa
p.Tests.dll

9 total, 0 failed, 0 skipped, took 1.981 seconds
D, [2011-03-18T10:24:26.234000 #2352] DEBUG -- : Executing XUnit: "c:/Projecten/Nancy/tools/xunit/xunit.console.clr4.x86
.exe" src/Nancy.BootStrappers.Unity.Tests/bin/Release/Nancy.BootStrappers.Unity.Tests.dll
xUnit.net console test runner (32-bit .NET 4.0.30319.1)
Copyright (C) 2007-10 Microsoft Corporation.

xunit.dll:     Version 1.7.0.1540
Test assembly: c:\Projecten\Nancy\src\Nancy.BootStrappers.Unity.Tests\bin\Release\Nancy.BootStrappers.Unity.Tests.dll

9 total, 0 failed, 0 skipped, took 1.888 seconds
D, [2011-03-18T10:24:29.828000 #2352] DEBUG -- : Executing XUnit: "c:/Projecten/Nancy/tools/xunit/xunit.console.clr4.x86
.exe" src/Nancy.BootStrappers.Windsor.Tests/bin/Release/Nancy.BootStrappers.Windsor.Tests.dll
xUnit.net console test runner (32-bit .NET 4.0.30319.1)
Copyright (C) 2007-10 Microsoft Corporation.

xunit.dll:     Version 1.7.0.1540
Test assembly: c:\Projecten\Nancy\src\Nancy.BootStrappers.Windsor.Tests\bin\Release\Nancy.BootStrappers.Windsor.Tests.dl
l

11 total, 0 failed, 0 skipped, took 2.731 seconds
D, [2011-03-18T10:24:34.718000 #2352] DEBUG -- : Executing XUnit: "c:/Projecten/Nancy/tools/xunit/xunit.console.clr4.x86
.exe" src/Nancy.Hosting.Aspnet.Tests/bin/Release/Nancy.Hosting.Aspnet.Tests.dll
xUnit.net console test runner (32-bit .NET 4.0.30319.1)
Copyright (C) 2007-10 Microsoft Corporation.

xunit.dll:     Version 1.7.0.1540
Test assembly: c:\Projecten\Nancy\src\Nancy.Hosting.Aspnet.Tests\bin\Release\Nancy.Hosting.Aspnet.Tests.dll

4 total, 0 failed, 0 skipped, took 4.797 seconds
D, [2011-03-18T10:24:40.187000 #2352] DEBUG -- : Executing XUnit: "c:/Projecten/Nancy/tools/xunit/xunit.console.clr4.x86
.exe" src/Nancy.Hosting.Wcf.Tests/bin/Release/Nancy.Hosting.Wcf.Tests.dll
xUnit.net console test runner (32-bit .NET 4.0.30319.1)
Copyright (C) 2007-10 Microsoft Corporation.

xunit.dll:     Version 1.7.0.1540
Test assembly: c:\Projecten\Nancy\src\Nancy.Hosting.Wcf.Tests\bin\Release\Nancy.Hosting.Wcf.Tests.dll

3 total, 0 failed, 0 skipped, took 19.153 seconds
D, [2011-03-18T10:25:01.078000 #2352] DEBUG -- : Executing XUnit: "c:/Projecten/Nancy/tools/xunit/xunit.console.clr4.x86
.exe" src/Nancy.Tests/bin/Release/Nancy.Tests.dll
xUnit.net console test runner (32-bit .NET 4.0.30319.1)
Copyright (C) 2007-10 Microsoft Corporation.

xunit.dll:     Version 1.7.0.1540
Test assembly: c:\Projecten\Nancy\src\Nancy.Tests\bin\Release\Nancy.Tests.dll

445 total, 0 failed, 0 skipped, took 33.312 seconds
D, [2011-03-18T10:25:38.234000 #2352] DEBUG -- : Executing XUnit: "c:/Projecten/Nancy/tools/xunit/xunit.console.clr4.x86
.exe" src/Nancy.ViewEngines.NDjango.Tests/bin/Release/Nancy.ViewEngines.NDjango.Tests.dll
xUnit.net console test runner (32-bit .NET 4.0.30319.1)
Copyright (C) 2007-10 Microsoft Corporation.

xunit.dll:     Version 1.7.0.1540
Test assembly: c:\Projecten\Nancy\src\Nancy.ViewEngines.NDjango.Tests\bin\Release\Nancy.ViewEngines.NDjango.Tests.dll

Nancy.ViewEngines.NDjango.Tests.NDjangoViewCompilerFixture.GetCompiledView_should_render_to_stream [FAIL]
   System.IO.FileNotFoundException : Could not load file or assembly 'FSharp.Core, Version=4.0.0.0, Culture=neutral, Pub
licKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Het systeem kan het opgegeven bestand niet vinden.
   Stack Trace:
      at Nancy.ViewEngines.NDjango.NDjangoViewEngine.<>c__DisplayClass7.b__6(Stream stream)
      c:\Projecten\Nancy\src\Nancy.ViewEngines.NDjango.Tests\NDjangoViewCompilerFixture.cs(30,0): at Nancy.ViewEngines.N
Django.Tests.NDjangoViewCompilerFixture.GetCompiledView_should_render_to_stream()

1 total, 1 failed, 0 skipped, took 1.596 seconds
F, [2011-03-18T10:25:41.109000 #2352] FATAL -- : XUnit Failed. See Build Log For Detail
rake aborted!
XUnit Failed. See Build Log For Detail

(See full trace by running task with --trace)

Nuget Nancy and Nancy.Hosting.SelfHosting failing

I installed both Nancy and Nancy.Hosting.SelfHosting from Nuget.org. I have this simple app:

public class Module : NancyModule
{
    public Module()
    {
        Get["/"] = x =>
        {
            return "Test";
        };
    }
}

public class Program
{
    static void Main(string[] args)
    {
        var host = new NancyHost(new Uri("http://localhost:12345/test/"));
        host.Start();
        Console.WriteLine("Nancy is running...");
        Console.ReadLine();
        host.Stop();
    }
}

When I run the app and visit the /test I get the MissingMethodException

Method not found: 'Void Nancy.Request..ctor(System.String, System.String,System.Collections.Generic.IDictionary`2<System.String,System.Collections.Generic.IEnumerable`1<System.String>>, System.IO.Stream, System.String, System.String)'.

The full stacktrace

at Nancy.Hosting.SelfHosting.NancyHost.ConvertRequestToNancyRequest(HttpListenerRequest request)
at Nancy.Hosting.SelfHosting.NancyHost.Listen()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()

When I run Nancy.Demo.Hosting.Self project from the master clone everything works fine. So, I guess the problem is with nuget Nancy and Nancy.Hosting.Selfhosting assemblies being out of sync.

Route conditions must be static

Non-static route conditions fail to work since the module is not initialized when the route is being matched from the cache. This is at least worth documenting explicitly, though I wonder if we shouldn't just apply the condition after the module has been initialized to allow for both.

Self and WCF hosting does not handle query string

I've tested this on my own WCF service + Nancy's SelfHosting.Demo project and it seems like if you have a route:

Get["/"] = x => { ... }

And you run it like:

http://localhost:8888/nancy/?q=keyword

It will fail to resolve the correct route and return a 404 response. This however, works perfectly fine if you use the ASP.net hosting method (i.e., have web.config in a web project).

I've only just discovered this, will take a deeper look and submit a test case; In the meantime, if you adjust Nancy.Hosting.Wcf.Tests.NancyWcfGenericServiceFixture's Should_be_able_to_get_any_header_from_selfhost URI component to include ?q=keyword the test fails with 404 error.

PS: sorry if the issue log is a little inconvenient. Will try and create my own branch/gist later in the day. I just wanted to get the issue out here for conversation in the meantime.

Typed Properties for well-know Http Headers

I think it would be very useful to have typed properties for all the well-know request and response headers (Accept, Authorization, etc). Today is a simple IDictionary<string, IEnumerable for the request and a IDictionary<string, string> for the response (Which is wrong I think as you can have multiple values for an specific header. For example, Accept-Ranges).

I can contribute this as a patch if you are interested.

Thanks
Pablo.

Creating hrefs to other stuff, irrespective of where the site is deployed

In MVC3/Razor you can create links to Url.Content("whatever") and it will be filled out with the correct path no matter where your site is deployed. We could do with something like this in Nancy (if there isn't a way to do it already) otherwise you have to make assumptions about where your site is deployed.

Cryptography Improvements

Rework of the crypto code to stop keys being generated each request and general refactoring / simplification.

Embedded views throws AmbiguousViewException

Recent changes to the view discovery mechanism results in embedded views throwing AmbiguousViewException. This issue has been individually confirmed by Andreas Håkansson, Robert Greyling and Roy Jacobs.

ArgumentException during bootstrapping when there are no views

Hi,

Recently there have been some refactorings in the bootstrappers and conventions, and now I get an ArgumentException in the DefaultViewLocator when it is trying to find views.

In my project I don't have any views since it is a REST-based app that only returns JSON.

I tried to patch this, but it seems that there are still additional exceptions being thrown during initial bootstrapping when I try to unit test everything, since the Nancy.Testing code only finds "FakeNancyModule" after the bootstrapping process, which seems to indicate that the bootstrapping process failed somehwere halfway through.

So I guess a "no views" application is not functioning properly at the moment. I can spend some time figuring out the exact cause, but I just want to put this out there, since it may be trivial to fix for you.

Roy

FakeRootPathProvider defaults to a null root path

So failing to set it causes the bootstrapper to explode because it can't resolve the directory view location provider).

Either need to default this to the entry assembly location, add a more meaningful error, or update the directory view location provider handle this more gracefully.

Default solution config doesn't build

Error 1 Metadata file '\src\Nancy.Hosting.Aspnet\bin\Debug\Nancy.Hosting.Aspnet.dll'

The default build config doesn't build some of the projects (AnyCPU is fine though)

HEAD requests are no longer working

It appears that there were removed while the IoC capabilities were being put in but never reimplemented after that. Most of the code is still there (even tests) but they have all been commented

StaticFileResponse should have caching built-in

As the name implied "static" it should be cache at by the client unless it's been changed (date modified) using ETag to tell the client that the content is not change and do not need to download the content of the file again.

Forms Authentication throws when Decrypting Authentication Cookie

When running the FormsAuth demo an error occurs in FormsAuthentication.DecryptAndValidateAuthenticationCookie. In the first few lines of that method pasted below, decodedCookie is 27 characters long and hmacStringLength = 28, which produces an ArgumentOutOfRangeException.

private static string DecryptAndValidateAuthenticationCookie(string cookieValue, FormsAuthenticationConfiguration configuration) 
    { 
        // TODO - shouldn't this be automatically decoded by nancy cookie when that change is made? 
        var decodedCookie = Helpers.HttpUtility.UrlDecode(cookieValue); 
        var hmacStringLength = Base64Helpers.GetBase64Length(configuration.HmacProvider.HmacLength); 
        var encryptedCookie = decodedCookie.Substring(hmacStringLength); 

request's GetCookieData should allow for = chars

The foreach should be limited to two elements:

foreach (var parts in cookies.Select(c => c.Split(new char[] {'='}, 2)))
            {
                if (parts.Length < 2) continue;
                cookieDictionary[parts[0].Trim()] = parts[1];
            }

Default bootstrapper with medium trust

The current ASP.NET Bootstrapper (and some underlying infrastructure) require permissions that are not available in the default medium trust configuration. One of the offenders is AppDomainAssemblyTypeScanner which tries to read Assembly.Location (FileIOPermission, PathDiscovery) which is done in the static constructor and thus hard to avoid.

I believe that the medium-trust-way to do stuff is to either register module types in web.config (and have a custom bootstrapper look them up) or add them to the ioc container from global.asax.

Can't match on paths containing ; or ,

The RESTful Web Services Cookbook says this:

Comma and semicolon

Use the comma (,) and semi-colon (;) characters to indicate nonhierarchical portions of the URI. The semicolon convention is used to identify matrix parameters:

http://www.example.org/co-ordinates;w=39.001409,z=-84.578201
http://www.example.org/axis;x=0,y=9

These characters are valid in the path and query portions of URIs, but not all code libraries recognize the comma and semicolon as separators and may require custom coding to extract these parameters.

But the default matcher doesn't capture paths containing ; or ,.

Nancy.Testing depends on xUnit.net 1.7.0 which is no longer available

This is something I reported to the NuGet guys months ago, but the official NuGet repository doesn't keep all old versions of packages. The Nancy.Testing package depends on the exact version 1.7.0.1540 which is no longer available, which results in the following error when upgrading (if you don't already happen to have the xUnit.net package installed):

------- Updating...Nancy.Testing 0.6.0 -------
Attempting to resolve dependency 'Nancy (= 0.6.0)'.
Attempting to resolve dependency 'xUnit.net (= 1.7.0.1540)'.
Unable to resolve dependency 'xUnit.net (= 1.7.0.1540)'.

Razor - "Error Compiling Template: (0, 0) No inputs specified)"

When your webproject is running from a location where you have e.g "#" in the path it doesn't work. Fix suggested below.

More info here: https://groups.google.com/group/nancy-web-framework/browse_thread/thread/e9d04b975635d7cb

Don't have the time to give you a fix on this, but it's located in the RazorViewEngine when it builds assemblypaths for assemblies to include when compiling the Razor view.

In the RazorViewEngine instead of:

private static string GetAssemblyPath(Assembly assembly) {
return new Uri(assembly.CodeBase).LocalPath;
}

perhaps use:

private static string GetAssemblyPath(Assembly assembly) {
return new Uri(assembly.EscapedCodeBase).LocalPath;
}

//Danieö

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.