Mundane.Hosting.AspNet 6.0.0

dotnet add package Mundane.Hosting.AspNet --version 6.0.0
NuGet\Install-Package Mundane.Hosting.AspNet -Version 6.0.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="Mundane.Hosting.AspNet" Version="6.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Mundane.Hosting.AspNet --version 6.0.0
#r "nuget: Mundane.Hosting.AspNet, 6.0.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 Mundane.Hosting.AspNet as a Cake Addin
#addin nuget:?package=Mundane.Hosting.AspNet&version=6.0.0

// Install Mundane.Hosting.AspNet as a Cake Tool
#tool nuget:?package=Mundane.Hosting.AspNet&version=6.0.0

<img align="left" width="116" src="https://raw.githubusercontent.com/adambarclay/mundane-hosting-aspnet/main/build/Mundane.png"/>

Mundane.Hosting.AspNet

License: MIT nuget build coverage

Mundane is a lightweight "no magic" web framework for .NET.

This package enables a Mundane application to be hosted with ASP.NET.

See the Mundane documentation for more information.

Getting Started

Install the Mundane.Hosting.AspNet nuget package, then in your ASP.NET startup code call app.UseMundane(); passing in the routing and dependencies configuration.

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        var dependencies = new Dependencies(
            new Dependency<Configuration>(new Configuration(env)),
            new Dependency<DataRepository>(request => new DataRepositorySqlServer(
                request.Dependency<Configuration>().ConnectionString)));

        var routing = new Routing(
            routeConfiguration =>
            {
                routeConfiguration.Get("/", HomeController.HomePage);
                routeConfiguration.Get("/data/{id}", DataController.GetData);
                routeConfiguration.Post("/data/{id}", DataController.UpdateData);
            });

        app.UseMundane(dependencies, routing);
    }

Executing Requests

Endpoints can be executed in a different part the ASP.NET pipeline by calling MundaneMiddleware.ExecuteRequest(). For example you may want to do custom error handling while still making use of the Mundane engine.

Passing the current HttpContext and the routing and dependencies configuration will execute the endpoint which matches the request.

    public static async ValueTask ExecuteRequest(
        HttpContext context,
        DependencyFinder dependencyFinder,
        Routing routing)

It is also possible to execute a specifc endpoint with:

    public static async ValueTask ExecuteRequest(
        HttpContext context,
        DependencyFinder dependencyFinder,
        MundaneEndpoint endpoint,
        Dictionary<string, string> routeParameters)

The endpoint must be a MundaneEndpoint which has the signature ValueTask<Response> Endpoint(Request request). Any of the other Mundane endpoint signatures can be converted to a MundaneEndpoint by calling MundaneEndpointFactory.Create() e.g.

    MundaneEndpointFactory.Create(() => Response.Ok(o => Write("Hello World!")));

Since there is no routing information in this version of ExecuteRequest(), you must also supply an appropriate routeParameters dictionary for the endpoint. When called as part of the pipeline, Mundane creates a dictionary of parameters captured from the URL, e.g. for the route /my-endpoint/{id}, called with /my-endpoint/123, Mundane passes new Dictionary<string, string> { { "id", "123" } } as routeParameters.

If the endpoint does not require route parameters, pass an empty dictionary: new Dictionary<string, string>(0);.

Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  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
6.0.0 340 11/11/2021
5.0.3 306 9/5/2021
5.0.2 347 6/3/2021
5.0.0 265 5/4/2021
4.0.0 298 2/17/2021
3.0.0 306 2/2/2021
2.0.0 451 12/12/2020
1.0.1 345 11/23/2020
1.0.0 412 11/17/2020