HODI 1.0.0

Package Description

There is a newer version of this package available.
See the version list below for details.
Install-Package HODI -Version 1.0.0
dotnet add package HODI --version 1.0.0
<PackageReference Include="HODI" Version="1.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add HODI --version 1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: HODI, 1.0.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install HODI as a Cake Addin
#addin nuget:?package=HODI&version=1.0.0

// Install HODI as a Cake Tool
#tool nuget:?package=HODI&version=1.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

HODI

Higher Order Dependency Injection

This set of functions was designed to be simple and consistent with a minimal implementation.

The purpose of this library is to make unit testing of functions used as HTTP handlers in F# web applications more straightforward.

Defining Handlers

Instead of...

let oldWayHandler : HttpHandler =
    fun (next: HttpFunc) (ctx: HttpContext) ->
        task {
            let dep = ctx.GetService<Dependency>()
            // ...
        }

this can be done...

let anotherWayHandler : HttpHandler =
    fun (dep: Dependency) (next: HttpFunc) (ctx: HttpContext) ->
        task {
            // ...
        }

Usage

The functions can be used when defining routes.

let app =
    choose [
        route "/a" >=> exampleHandler |> inject
        route "/b" >=> handlerWith2Dependencies |> inject2
        routef "/c/%s" >=> handlerWithArgumentAndDependency |> injectPlus
    ]

Unit Testing

When unit testing the HTTPHandler functions, you could simply pass the dependencies without having to set up a test server.
In other words, the tests can focus on the handlers behavior instead of caring about dependency injection.

HODI

Higher Order Dependency Injection

This set of functions was designed to be simple and consistent with a minimal implementation.

The purpose of this library is to make unit testing of functions used as HTTP handlers in F# web applications more straightforward.

Defining Handlers

Instead of...

let oldWayHandler : HttpHandler =
    fun (next: HttpFunc) (ctx: HttpContext) ->
        task {
            let dep = ctx.GetService<Dependency>()
            // ...
        }

this can be done...

let anotherWayHandler : HttpHandler =
    fun (dep: Dependency) (next: HttpFunc) (ctx: HttpContext) ->
        task {
            // ...
        }

Usage

The functions can be used when defining routes.

let app =
    choose [
        route "/a" >=> exampleHandler |> inject
        route "/b" >=> handlerWith2Dependencies |> inject2
        routef "/c/%s" >=> handlerWithArgumentAndDependency |> injectPlus
    ]

Unit Testing

When unit testing the HTTPHandler functions, you could simply pass the dependencies without having to set up a test server.
In other words, the tests can focus on the handlers behavior instead of caring about dependency injection.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.2.0 52 4/26/2021
1.1.1 36 4/24/2021
1.1.0 39 4/22/2021
1.0.3 54 4/22/2021
1.0.2 119 4/18/2021
1.0.1 64 4/16/2021
1.0.0 45 4/16/2021
Show less