HODI 2.4.1

dotnet add package HODI --version 2.4.1
                    
NuGet\Install-Package HODI -Version 2.4.1
                    
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="2.4.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="HODI" Version="2.4.1" />
                    
Directory.Packages.props
<PackageReference Include="HODI" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add HODI --version 2.4.1
                    
#r "nuget: HODI, 2.4.1"
                    
#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.
#:package HODI@2.4.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=HODI&version=2.4.1
                    
Install as a Cake Addin
#tool nuget:?package=HODI&version=2.4.1
                    
Install as a Cake Tool

HODI

Logo of HODI

Higher Order Dependency Injection

HODI is a set of functions designed to be simple and consistent with a minimal implementation.

NuGet Downloads Coverage Status

Why HODI?

  • Testable by default: pass dependencies as arguments, not service locators
  • Type-safe: compiler catches missing deps before runtime
  • Works with Giraffe/web handlers

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 net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.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.4.1 168 7/26/2026
2.3.0 143 7/14/2026
2.2.0 357 5/13/2025
2.1.1 278 8/15/2023
2.0.6 423 1/21/2023
2.0.5 423 1/21/2023
2.0.3 455 1/21/2023
2.0.1 553 10/26/2022
2.0.0 656 4/3/2022
1.2.5 603 4/3/2022
1.2.4 621 4/2/2022
1.2.3 607 4/2/2022
1.2.2 498 9/28/2021
1.2.0 547 4/26/2021
1.1.1 563 4/24/2021
1.1.0 528 4/22/2021
1.0.3 527 4/22/2021
1.0.2 572 4/18/2021
1.0.1 526 4/16/2021
Loading failed