Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[csharp] Update to GenHTTP 9.6 and use a regular handler for JSON #9568

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
15 changes: 7 additions & 8 deletions frameworks/CSharp/genhttp/Benchmarks/Benchmarks.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,21 @@
</PropertyGroup>

<ItemGroup>
<None Remove="Resources\Fortunes.html"/>
<None Remove="Resources\Template.html"/>
<None Remove="Resources\Fortunes.html" />
<None Remove="Resources\Template.html" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Resources\Template.html"/>
<EmbeddedResource Include="Resources\Template.html" />
</ItemGroup>

<ItemGroup>

<PackageReference Include="GenHTTP.Core.Kestrel" Version="9.0.0" />
<PackageReference Include="GenHTTP.Modules.Razor" Version="8.6.0" />
<PackageReference Include="GenHTTP.Modules.Webservices" Version="9.0.0" />
<PackageReference Include="GenHTTP.Core" Version="9.6.2" />
<PackageReference Include="GenHTTP.Modules.Webservices" Version="9.6.2" />

<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.0" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="9.0.1" />
<PackageReference Include="Npgsql.EntityFrameworkCore.PostgreSQL" Version="9.0.3" />

</ItemGroup>

Expand Down
6 changes: 4 additions & 2 deletions frameworks/CSharp/genhttp/Benchmarks/Program.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
using Benchmarks.Tests;
using Benchmarks.Utilities;
using GenHTTP.Engine.Kestrel;

using GenHTTP.Engine.Internal;

using GenHTTP.Modules.IO;
using GenHTTP.Modules.Layouting;
using GenHTTP.Modules.Webservices;

var tests = Layout.Create()
.Add("plaintext", Content.From(Resource.FromString("Hello, World!")))
.Add("json", new JsonHandler())
.Add("fortunes", new FortuneHandler())
.AddService<JsonResource>("json")
.AddService<DbResource>("db")
.AddService<QueryResource>("queries")
.AddService<UpdateResource>("updates")
Expand Down
39 changes: 39 additions & 0 deletions frameworks/CSharp/genhttp/Benchmarks/Tests/JsonHandler.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System.Text.Json;

using GenHTTP.Api.Content;
using GenHTTP.Api.Protocol;

using GenHTTP.Modules.Conversion.Serializers.Json;

namespace Benchmarks.Tests;

public sealed class JsonResult
{

public string Message { get; set; }
}

public sealed class JsonHandler : IHandler
{
private static readonly FlexibleContentType _ContentType = new(ContentType.ApplicationJson, "utf-8");

private static readonly JsonSerializerOptions _Options = new();

public ValueTask PrepareAsync() => new();

public ValueTask<IResponse> HandleAsync(IRequest request)
{
var result = new JsonResult()
{
Message = "Hello, World!"
};

var response = request.Respond()
.Content(new JsonContent(result, _Options))
.Type(_ContentType)
.Build();

return new(response);
}

}
20 changes: 0 additions & 20 deletions frameworks/CSharp/genhttp/Benchmarks/Tests/JsonResource.cs

This file was deleted.

5 changes: 5 additions & 0 deletions frameworks/CSharp/genhttp/genhttp.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ RUN dotnet publish -c release -o /app -r linux-musl-x64 --no-restore --self-cont

# final stage/image
FROM mcr.microsoft.com/dotnet/runtime-deps:9.0-alpine

ENV DOTNET_GCDynamicAdaptationMode=0
ENV DOTNET_ReadyToRun=0
ENV DOTNET_HillClimbing_Disable=1

WORKDIR /app
COPY --from=build /app .

Expand Down
Loading