The guys catch up with Andreas and Steve on what’s new in NancyFx (a web framework for .NET that was originally inspired by Sinatra).
Download / Listen:
Herding Code 156 – Catching up with Andreas Håkansson and Steven Robbins on NancyFx [audio:http://herdingcode.com/wp-content/uploads/HerdingCode-0156-NancyFx.mp3]
- Jon asks for a quick overview of NancyFx. Steve and Andreas both say you can write the same app on any number of web frameworks, so what really distinguishes them is the syntax and feel. Andreas says that the web only has a small set of things you really can do – there are only a few HTTP methods – but an infinite number of ways you can build applications; Nancy is one of them.
- Andreas says Diagnostics is a website built into Nancy itself. It covers things like request tracing and interactive diagnostics.
- Steve explains how the interactive diagnostics lets you find out what routes were hit and why, poke at live code, etc.
- Jon says the code for Diagnostics seems like pretty good sample code for getting an idea of how Nancy code works.
- Jon asks about how authentication is handled to restrict access.
- Content Negotiation
- Andreas explains how routes just return models, and the formatting is handled by response processors. There’s a syntax to allow for more control at the route level if needed.
- Steve says the response processors are allowed to participate in the selection by specifying how applicable they are for both content types and model types. The content negotiation can also allow you to select different models based on the request, avoiding unnecessary code from executing and weighing the model down unnecessarily.
- Serializers and dependencies
- Jon asks about the JSON serializers they’re using, and why they’re not using something like ServiceStack or JSON.NET. Andreas explains that because the Nancy core ships without dependencies, they used Mono code.
- Jon asks about where Nancy can be be embedded, outside of standard web hosting scenarios.
- Steve says that because Nancy doesn’t have other dependencies and is strictly focused on returning a response for a request, it’s extremely easy to test.
- Andreas points out that you can use other serializers very easily via a NuGet package.
- Jon asks about how packages work in Nancy. Andreas explains how Nancy scans for classes that implement ISerializer.
- Kevin asks about implementing a processor for generating hyperlinks between models.
- Jon asks if people are sharing processors. Steve says that they’re so trivial to write that there’s no real point in sharing them.
- Andreas says this was a community contribution. There are several conventions (including querystring values, URL segments) which can be used to set the culture for the context. There’s a helper on the Razor base class that returns a dynamic object which can return localized values from a resource. Assembly resources are used by default, but you can add others.
- Steve says that you can also use localized views based on filename.
- Jon asks for more information on how you’d set up a custom resource location.
- Architecture, pipelines, and IoC
- Jon says that he spoke with Jeremy Miller at Codemash, and Jeremy said that it took a while to get the processor architecture set up, but now it’s very easy to add in features. It seems like that’s also paid off for Nancy. Andreas agrees, the pipeline system and dependency injection really simplify adding in new features.
- Jon asks about how Nancy uses TinyIoC and how you could use TinyIoC in other applications.
- Kevin and Jon ask about how Steve wrote TinyIoC to run on multiple platforms. Steve describes some issues they’ve worked around and how assembly scanning can get tricky due to test frameworks injecting things into the app domain.
- Non-standard uses of Nancy
- Jon asks for some examples. Steve says they seen people embed it into WPF applications for an interface, to provide mobile support, and even on Raspberry Pi. They’d love to hear more about what people are doing with it.
- Questions from Twitter / Misc. Questions
- Jim Liddell (@liddellj) asks about the roadmap. Steve talks about work they’re doing for OWIN and Async support.
- Filip W (@filip_woj) asks "Why tuples instead of classes and structs?"
- Kristof Claes (@kristofclaes) asks "How do they determine when something is "too much ceremony"? Gut feeling? Set of defined rules? Talk? Compare to other FX?"
- Ian Battersby (@Cranialstrain) asks "Why dynamic? And don’t say fluency ;)"
- Tobi Tobsen (@t0bit0bsen) asks "Is there a NancyFx tutorial for devs w/o a background in web development or should they look elsewhere?"
- Jim Liddell (@liddellj) asks "How do you view Nancy in relation to similar frameworks, such as OpenRasta?"
- Kevin asks about asset management for Nancy. Steve says that’s probably better handled by external
- Kevin asks about web socket support. Steve says just use SignalR.
- There’s a Nancy store now.
- Daniel Lee (@danlimerick) asks "How many hours a week do you spend on Nancy? What’s ratio of reviewing PR’s vs writing new features?"
- Jon asks what Steve and Andreas are finding fun and interesting lately. Steve and Andreas both like Mongo.
- Scott K. asks if they’ll add time zone localization support. They tell him to submit a pull request.