LegendaryB.Cherry 1.0.4

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

// Install LegendaryB.Cherry as a Cake Tool
#tool nuget:?package=LegendaryB.Cherry&version=1.0.4


A simple http server implementation with a few goodies built around NET's HttpListener.

🎯 Features

  • Built around .NET's HttpListener
  • Setup of the HttpServer instance via a fluent api
  • Lightweight. The only dependency is Microsoft.Extensions.Logging.Abstractions to make logging of internal events possible
  • Built-in HttpRouter is interchangeable by implementing the interface IHttpRouter and calling HttpServer.Use<MyRouter>()
  • HTTP Controller support (limited to POST, GET, PUT, DELETE, but extendable)
    • Use Func<THttpRequest, THttpRespoonse, Task> to implement controllers
  • Middleware support
    • Use Func<THttpContext, Task> to implement custom middlewares

📝 Usage

namespace Cherry.ConsoleApp
    public class User
        public string Name => "Daniel";
        public string Mail => "daniel@github.com";

    public class JsonContentTypeMiddleware : IMiddleware
        public Task HandleRequestAsync(
            HttpListenerRequest req,
            HttpListenerResponse res)
            res.ContentType = MediaTypeNames.Application.Json;
            return Task.CompletedTask;

    public class HelloWorldController : HttpController
        public override Task HandleGetAsync(HttpListenerRequest req, HttpListenerResponse res)
            return res.AnswerWithStatusCodeAsync(
                "Hello World!",

    public class UserController : HttpController
        public override Task HandleGetAsync(HttpListenerRequest req, HttpListenerResponse res)
            return base.HandleGetAsync(req, res);

    public class Program
        static async Task Main()
            var server = new HttpServer(NullLogger<HttpServer>.Instance, "http://localhost:8081/")
                .RegisterMiddleware<JsonContentTypeMiddleware>() // installs a global middleware because no specific route was provided
                .RegisterController<HelloWorldController>("/api/v1/hello") // Path must be provided because the class is not decorated with the route attribute
                .RegisterController<UserController>(); // No path must be provided, because the class is decorated with the Route attribute

            // server.AutoRegisterControllers(); // Can be used to automatically discover controllers from a given assembly. Uses reflection and ignores all types which are not decorated with the Route attribute and inheriting from the HttpController base class

            await server.RunAsync();
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
1.0.4 337 12/8/2022