Skip to content

Commit b08578a

Browse files
authored
update sisk cadente tests (#9576)
* update sisk cadente * add missing dependencies to aot test * remove aot test * fix: plaintext strings * update cadente version * update cadente version
1 parent 176b408 commit b08578a

File tree

5 files changed

+47
-31
lines changed

5 files changed

+47
-31
lines changed

frameworks/CSharp/sisk/config.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,4 @@ os = "Linux"
2525
orm = "Raw"
2626
platform = ".NET"
2727
webserver = "Cadente"
28-
versus = "None"
28+
versus = "None"

frameworks/CSharp/sisk/sisk-cadente.dockerfile

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
1+
FROM mcr.microsoft.com/dotnet/sdk:9.0 AS build
22
WORKDIR /source
33

44
# copy csproj and restore as distinct layers
@@ -7,10 +7,14 @@ RUN dotnet restore -r linux-musl-x64
77

88
# copy and publish app and libraries
99
COPY sisk-cadente/ .
10-
RUN dotnet publish -c release -o /app -r linux-musl-x64
10+
RUN dotnet publish -c release -o /app
11+
12+
ENV DOTNET_GCDynamicAdaptationMode=0
13+
ENV DOTNET_ReadyToRun=0
14+
ENV DOTNET_HillClimbing_Disable=1
1115

1216
# final stage/image
13-
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS runtime
17+
FROM mcr.microsoft.com/dotnet/aspnet:9.0 AS runtime
1418
WORKDIR /app
1519
COPY --from=build /app .
1620

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
1-
using System.Text;
1+
using System.Net;
2+
using System.Text;
23
using System.Text.Json;
34
using Sisk.Cadente;
45

5-
var host = new HttpHost ( 8080, session => {
6-
var request = session.Request;
6+
HttpHost.QueueSize = 4096;
7+
8+
var host = new HttpHost ( new IPEndPoint ( IPAddress.Any, 8080 ) );
9+
host.ContextCreated += Host_ContextCreated;
10+
11+
host.Start ();
12+
Thread.Sleep ( Timeout.Infinite );
713

14+
void Host_ContextCreated ( HttpHost sender, HttpHostContext session ) {
15+
var request = session.Request;
16+
817
if (request.Path == "/plaintext") {
918
SerializePlainTextResponse ( session.Response );
1019
}
@@ -14,23 +23,22 @@
1423
else {
1524
session.Response.StatusCode = 404;
1625
}
17-
} );
26+
}
1827

19-
host.Start ();
20-
Thread.Sleep ( Timeout.Infinite );
28+
static void SerializePlainTextResponse ( HttpHostContext.HttpResponse response ) {
2129

22-
static void SerializePlainTextResponse ( HttpResponse response ) {
23-
var contentBytes = Encoding.UTF8.GetBytes ( "Hello, world!" );
30+
var messageBytes = Encoding.UTF8.GetBytes ( "Hello, World!" );
2431

25-
response.Headers.Add ( new HttpHeader ( "Content-Type", "text/plain" ) );
26-
response.ResponseStream = new MemoryStream ( contentBytes );
32+
response.Headers.Add ( new HttpHeader ( "Content-Type", "text/plain; charset=UTF-8" ) );
33+
response.ResponseStream = new MemoryStream ( messageBytes );
2734
}
2835

29-
static void SerializeJsonResponse ( HttpResponse response ) {
36+
static void SerializeJsonResponse ( HttpHostContext.HttpResponse response ) {
37+
3038
var contentBytes = JsonSerializer.SerializeToUtf8Bytes ( new {
31-
message = "Hello, world!"
39+
message = "Hello, World!"
3240
} );
33-
34-
response.Headers.Add ( new HttpHeader ( "Content-Type", "application/json; charset=utf-8" ) );
41+
42+
response.Headers.Add ( new HttpHeader ( "Content-Type", "application/json" ) );
3543
response.ResponseStream = new MemoryStream ( contentBytes );
3644
}
Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

3-
<PropertyGroup>
4-
<OutputType>Exe</OutputType>
5-
<TargetFramework>net8.0</TargetFramework>
6-
<ImplicitUsings>enable</ImplicitUsings>
7-
<Nullable>enable</Nullable>
8-
<ServerGarbageCollection>true</ServerGarbageCollection>
9-
</PropertyGroup>
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net9.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
<ServerGarbageCollection>true</ServerGarbageCollection>
9+
</PropertyGroup>
1010

11-
<ItemGroup>
12-
<PackageReference Include="Sisk.Cadente" Version="0.1.42-alpha1" />
13-
</ItemGroup>
11+
<ItemGroup>
12+
<PackageReference Include="Sisk.Cadente" Version="0.1.64-alpha4" />
13+
</ItemGroup>
1414

15-
</Project>
15+
</Project>
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
using System.Net.Http.Json;
2+
using System.Text;
23
using Sisk.Core.Http;
34
using Sisk.Core.Routing;
45

56
var app = HttpServer.CreateBuilder ( host => {
67
host.UseListeningPort ( "http://+:8080/" );
8+
host.UseConfiguration ( config => {
9+
config.AccessLogsStream = null;
10+
} );
711
} ).Build ();
812

913
app.Router.SetRoute ( RouteMethod.Get, "/plaintext", PlainText );
@@ -12,11 +16,11 @@
1216
app.Start ();
1317

1418
static HttpResponse PlainText ( HttpRequest request ) {
15-
return new HttpResponse ( "Hello, world!" );
19+
return new HttpResponse ( new StringContent ( "Hello, World!", Encoding.UTF8, "text/plain" ) );
1620
}
1721

1822
static HttpResponse Json ( HttpRequest request ) {
1923
return new HttpResponse ( JsonContent.Create ( new {
20-
message = "Hello, world!"
24+
message = "Hello, World!"
2125
} ) );
2226
}

0 commit comments

Comments
 (0)