HODI 1.1.0

There is a newer version of this package available.
See the version list below for details.
dotnet add package HODI --version 1.1.0
NuGet\Install-Package HODI -Version 1.1.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="HODI" Version="1.1.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add HODI --version 1.1.0
#r "nuget: HODI, 1.1.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. 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.1.0

// Install HODI as a Cake Tool
#tool nuget:?package=HODI&version=1.1.0

HODI

HODI

Higher Order Dependency Injection

HODI is a set of functions 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.

NuGet Info

.NET Coverage Status

Install

PM> Install-Package HODI

or...

dotnet add package HODI

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.

Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
2.1.1 121 8/15/2023
2.0.6 237 1/21/2023
2.0.5 241 1/21/2023
2.0.3 254 1/21/2023
2.0.1 342 10/26/2022
2.0.0 403 4/3/2022
1.2.5 390 4/3/2022
1.2.4 401 4/2/2022
1.2.3 388 4/2/2022
1.2.2 287 9/28/2021
1.2.0 296 4/26/2021
1.1.1 284 4/24/2021
1.1.0 284 4/22/2021
1.0.3 294 4/22/2021
1.0.2 350 4/18/2021
1.0.1 296 4/16/2021
1.0.0 304 4/16/2021