Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Http11Probe.slnx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<Folder Name="/src/Servers/">
<Project Path="src/Servers/AspNetMinimal/AspNetMinimal.csproj" />
<Project Path="src/Servers/EmbedIOServer/EmbedIOServer.csproj" />
<Project Path="src/Servers/FastEndpointsServer/FastEndpointsServer.csproj" />
<Project Path="src/Servers/GenHttpServer/GenHttpServer.csproj" />
<Project Path="src/Servers/GlyphServer/GlyphServer.csproj" />
<Project Path="src/Servers/NetCoreServerFramework/NetCoreServerFramework.csproj" />
Expand Down
150 changes: 150 additions & 0 deletions docs/content/servers/fastendpoints.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
---
title: "FastEndpoints"
toc: false
breadcrumbs: false
---

**Language:** C# · [View source on GitHub](https://github.com/MDA2AV/Http11Probe/tree/main/src/Servers/FastEndpointsServer)

## Dockerfile

```dockerfile
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
COPY Directory.Build.props .
COPY src/Servers/FastEndpointsServer/ src/Servers/FastEndpointsServer/
RUN dotnet restore src/Servers/FastEndpointsServer/FastEndpointsServer.csproj
RUN dotnet publish src/Servers/FastEndpointsServer/FastEndpointsServer.csproj -c Release -o /app --no-restore

FROM mcr.microsoft.com/dotnet/aspnet:10.0
WORKDIR /app
COPY --from=build /app .
ENTRYPOINT ["dotnet", "FastEndpointsServer.dll"]
```

## Source — `Program.cs`

```csharp
using FastEndpoints;

var builder = WebApplication.CreateBuilder(args);

builder.WebHost.UseUrls("http://+:8080");
builder.Services.AddFastEndpoints(o => o.Assemblies = [typeof(GetRoot).Assembly]);

var app = builder.Build();

app.UseFastEndpoints();

app.Run();

// ── GET / ──────────────────────────────────────────────────────

sealed class GetRoot : EndpointWithoutRequest
{
public override void Configure()
{
Get("/");
AllowAnonymous();
}

public override async Task HandleAsync(CancellationToken ct)
{
await HttpContext.Response.WriteAsync("OK", ct);
}
}

// ── HEAD / ─────────────────────────────────────────────────────

sealed class HeadRoot : EndpointWithoutRequest
{
public override void Configure()
{
Verbs("HEAD");
Routes("/");
AllowAnonymous();
}

public override async Task HandleAsync(CancellationToken ct)
{
HttpContext.Response.StatusCode = 200;
await HttpContext.Response.WriteAsync("", ct);
}
}

// ── POST / ─────────────────────────────────────────────────────

sealed class PostRoot : EndpointWithoutRequest
{
public override void Configure()
{
Post("/");
AllowAnonymous();
}

public override async Task HandleAsync(CancellationToken ct)
{
using var reader = new StreamReader(HttpContext.Request.Body);
var body = await reader.ReadToEndAsync(ct);
await HttpContext.Response.WriteAsync(body, ct);
}
}

// ── OPTIONS / ──────────────────────────────────────────────────

sealed class OptionsRoot : EndpointWithoutRequest
{
public override void Configure()
{
Verbs("OPTIONS");
Routes("/");
AllowAnonymous();
}

public override async Task HandleAsync(CancellationToken ct)
{
HttpContext.Response.Headers["Allow"] = "GET, HEAD, POST, OPTIONS";
HttpContext.Response.StatusCode = 200;
await HttpContext.Response.WriteAsync("", ct);
}
}

// ── POST /echo ─────────────────────────────────────────────────

sealed class PostEcho : EndpointWithoutRequest
{
public override void Configure()
{
Post("/echo");
AllowAnonymous();
}

public override async Task HandleAsync(CancellationToken ct)
{
var sb = new System.Text.StringBuilder();
foreach (var h in HttpContext.Request.Headers)
foreach (var v in h.Value)
sb.AppendLine($"{h.Key}: {v}");
await HttpContext.Response.WriteAsync(sb.ToString(), ct);
}
}
```

## Source — `FastEndpointsServer.csproj`

```xml
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FastEndpoints" Version="7.2.0" />
</ItemGroup>

</Project>
```
1 change: 1 addition & 0 deletions docs/static/probe/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ window.ProbeRender = (function () {
'EmbedIO': '/Http11Probe/servers/embedio/',
'Envoy': '/Http11Probe/servers/envoy/',
'Express': '/Http11Probe/servers/express/',
'FastEndpoints': '/Http11Probe/servers/fastendpoints/',
'FastHTTP': '/Http11Probe/servers/fasthttp/',
'Flask': '/Http11Probe/servers/flask/',
'GenHTTP': '/Http11Probe/servers/genhttp/',
Expand Down
11 changes: 11 additions & 0 deletions src/Servers/FastEndpointsServer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
FROM mcr.microsoft.com/dotnet/sdk:10.0 AS build
WORKDIR /src
COPY Directory.Build.props .
COPY src/Servers/FastEndpointsServer/ src/Servers/FastEndpointsServer/
RUN dotnet restore src/Servers/FastEndpointsServer/FastEndpointsServer.csproj
RUN dotnet publish src/Servers/FastEndpointsServer/FastEndpointsServer.csproj -c Release -o /app --no-restore

FROM mcr.microsoft.com/dotnet/aspnet:10.0
WORKDIR /app
COPY --from=build /app .
ENTRYPOINT ["dotnet", "FastEndpointsServer.dll"]
14 changes: 14 additions & 0 deletions src/Servers/FastEndpointsServer/FastEndpointsServer.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="FastEndpoints" Version="7.2.0" />
</ItemGroup>

</Project>
103 changes: 103 additions & 0 deletions src/Servers/FastEndpointsServer/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
using FastEndpoints;

var builder = WebApplication.CreateBuilder(args);

builder.WebHost.UseUrls("http://+:8080");
builder.Services.AddFastEndpoints(o => o.Assemblies = [typeof(GetRoot).Assembly]);

var app = builder.Build();

app.UseFastEndpoints();

app.Run();

// ── GET / ──────────────────────────────────────────────────────

sealed class GetRoot : EndpointWithoutRequest
{
public override void Configure()
{
Get("/");
AllowAnonymous();
}

public override async Task HandleAsync(CancellationToken ct)
{
await HttpContext.Response.WriteAsync("OK", ct);
}
}

// ── HEAD / ─────────────────────────────────────────────────────

sealed class HeadRoot : EndpointWithoutRequest
{
public override void Configure()
{
Verbs("HEAD");
Routes("/");
AllowAnonymous();
}

public override async Task HandleAsync(CancellationToken ct)
{
HttpContext.Response.StatusCode = 200;
await HttpContext.Response.WriteAsync("", ct);
}
}

// ── POST / ─────────────────────────────────────────────────────

sealed class PostRoot : EndpointWithoutRequest
{
public override void Configure()
{
Post("/");
AllowAnonymous();
}

public override async Task HandleAsync(CancellationToken ct)
{
using var reader = new StreamReader(HttpContext.Request.Body);
var body = await reader.ReadToEndAsync(ct);
await HttpContext.Response.WriteAsync(body, ct);
}
}

// ── OPTIONS / ──────────────────────────────────────────────────

sealed class OptionsRoot : EndpointWithoutRequest
{
public override void Configure()
{
Verbs("OPTIONS");
Routes("/");
AllowAnonymous();
}

public override async Task HandleAsync(CancellationToken ct)
{
HttpContext.Response.Headers["Allow"] = "GET, HEAD, POST, OPTIONS";
HttpContext.Response.StatusCode = 200;
await HttpContext.Response.WriteAsync("", ct);
}
}

// ── POST /echo ─────────────────────────────────────────────────

sealed class PostEcho : EndpointWithoutRequest
{
public override void Configure()
{
Post("/echo");
AllowAnonymous();
}

public override async Task HandleAsync(CancellationToken ct)
{
var sb = new System.Text.StringBuilder();
foreach (var h in HttpContext.Request.Headers)
foreach (var v in h.Value)
sb.AppendLine($"{h.Key}: {v}");
await HttpContext.Response.WriteAsync(sb.ToString(), ct);
}
}
1 change: 1 addition & 0 deletions src/Servers/FastEndpointsServer/probe.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"name": "FastEndpoints", "language": "C#"}