Effortless REST API Development with C#

A configuration-free, embeddable alternative to ASP.NET Core for building REST APIs on .NET.

dotnet add package GenHTTP.Full

Open source under the MIT license, on NuGet for .NET 10 and later.

Service

C#
using GenHTTP.Engine.Internal;
using GenHTTP.Modules.Functional;
using GenHTTP.Modules.Practices;

// http://localhost:8080/users/42

var api = Inline.Create()
    .Get("/users/:id", (int id) => new User(id, "Jane"));

await Host.Create()
    .Handler(api)
    .Defaults()
    .RunAsync();

public record User(int Id, string Name);

Open API

C#
using GenHTTP.Engine.Internal;
using GenHTTP.Modules.Functional;
using GenHTTP.Modules.OpenApi;
using GenHTTP.Modules.Practices;

// http://localhost:8080/openapi.json

var api = Inline.Create()
    .Get("/users/:id", (int id) => new User(id, "Jane"))
    .AddOpenApi();

await Host.Create()
    .Handler(api)
    .Defaults()
    .RunAsync();

public record User(int Id, string Name);

JWT

C#
using GenHTTP.Engine.Internal;
using GenHTTP.Modules.Authentication;
using GenHTTP.Modules.Functional;
using GenHTTP.Modules.OpenApi;
using GenHTTP.Modules.Practices;

var auth = BearerAuthentication.Create()
    .Issuer("https://sso.example.com/");

var api = Inline.Create()
    .Get("/users/:id", (int id) => new User(id, "Jane"))
    .AddOpenApi()
    .Add(auth);

await Host.Create()
    .Handler(api)
    .Defaults()
    .RunAsync();

public record User(int Id, string Name);
What is included

A web server you add like any other package

No configuration files, no hosting model to learn. GenHTTP is a library you reference, configure in code and run wherever your application runs.

The fastest web server for HTTP/1.1

According to HTTP Arena, stock GenHTTP is 1.5 times faster than ASP.NET Core Minimal API in a mixed challenge with different use cases and usage scenarios.

Performance, footprint and security

Composite HTTP/1.1 score of C# frameworks, measured by HTTP Arena
  1. genhttp-ioxide 6,211
  2. genhttp 4,088
  3. simplew 3,671
  4. genhttp-kestrel 2,992
  5. carter 2,978
  6. aspnet-minimal 2,715
  7. fastendpoints 2,660
  8. sisk 2,047
  9. servicestack 237

One application, three engines

Replace the HTTP engine without touching your application code - change the package and the Host namespace you import.

Pick the framework that fits your application

Every framework runs on the same server and the same modules, so you can mix them within one application.

All about frameworks

Talk to us

Questions, ideas or a project of your own - the community and the team behind GenHTTP are glad to help.