Mini-Training: NancyFX

Preview:

DESCRIPTION

Discover in this mini-training what NancyFX is: a Lightweight Web Framework for .net

Citation preview

NancyFX The super-duper-happy-path

Overview

• Designed for building HTTP based services on .NET and Mono.

• Prioritise conventions over configurations

• Provides an easy Domain Specific Language

• Open-source under MIT license

• No dependencies on existing framework

• Can be used over different hosting environment (ASP.NET, WCF, …) using specific host implementations

• Handle DELETE, GET, HEAD, OPTIONS, POST, PUT, PATCH requests

• Integrate view engines (Razor, Spark, dotLiquid, its own SuperSimpleViewEngine, and more)

• Advanced routing and parameter capabilities

• Easy response syntax

• Embark its own testing framework

• Model binding

3

Features

The super-what ?

• This is the ethos the team is striving for, but here are the basic ideas behind it :

– It just works – little to no configuration even when adding modules, viewengines, dependencies, etc.

– Easily customisable – possibility to redefine each pieces of the frameworks

– Low ceremony – minimal amount of « Nancy code », focus is on the application code

– Low friction – easy usage of the framework without sacrificing extensibility and power when you need it

• Define the behavior of your application

• Must inherit NancyModule and are globally discovered

5

Modules

• A lot of common things with ASP.NET MVC routing

• Main differencies :

– Defined in a module constructor

– Each capturing segment pattern has a score

– The route which has the best score (combining all the matching segments scores) has the priority

– The order of route loading is not important unless two matching routes have the same score

6

Routing

• Aggregate all the framework pieces together

• Responsible of the automatic discovery of modules, model binders, dependencies, etc.

• Built on top of a IoC container (TinyIoc)

• Can be replaced with another container (already available : ninject, structuremap, unity and more)

• Can be overrided to change or add features

7

Bootstrapper

• Takes a “template” and an optional “model” and usually render HTML

• Shipped with the SuperSimpleViewEngine (.html and .sshtml files) but can be replaced

• Just adding a reference to them via the separate nuget package will make them available

• Possibility to implement your own view engine and hook it up like any other

8

View engines

9

Some other frameworks

• FubuMVC

– compositional, convention-based framework for complex web applications

• OpenRasta

– open-source .NET framework for building everything web, from web sites to RESTful APIs

And of course :

• ASP.NET MVC

– You should already know what to insert here…

• Modules and application hooks

• Content negociation

• Authentication

• Hosting and implementing a host

• Application testing

• Diagnostics and dashboard

• Cryptography

11

And some more things

13

Questions

Find out more

• On https://techblog.betclicgroup.com/

About Betclic • Betclic Everest Group, one of the world leaders in online gaming, has a unique

portfolio comprising various complementary international brands: Betclic, Everest Gaming, bet-at-home.com, Expekt…

• Active in 100 countries with more than 12 million customers worldwide, the Group is committed to promoting secure and responsible gaming and is a member of several international professional associations including the EGBA (European Gaming and Betting Association) and the ESSA (European Sports Security Association).

• Through our brands, Betclic Everest Group places expertise, technological know-how and security at the heart of our strategy to deliver an on-line gaming offer attuned to the passion of our players.