diff options
author | crupest <crupest@outlook.com> | 2022-12-02 13:23:40 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-12-02 13:35:35 +0800 |
commit | cf85a3edda5953581dd1226fb0c7a1923a405da6 (patch) | |
tree | 59f4e3942cc35664993f8bb8b9e4f7bf2ff4f3a3 | |
parent | 879fb614c6853ab3bb83155c82722afb2933fc60 (diff) | |
download | crupest-cf85a3edda5953581dd1226fb0c7a1923a405da6.tar.gz crupest-cf85a3edda5953581dd1226fb0c7a1923a405da6.tar.bz2 crupest-cf85a3edda5953581dd1226fb0c7a1923a405da6.zip |
Fix crupest-api bug.
6 files changed, 20 insertions, 16 deletions
diff --git a/docker/crupest-api/CrupestApi/CrupestApi.Commons/CrupestApi.Commons.csproj b/docker/crupest-api/CrupestApi/CrupestApi.Commons/CrupestApi.Commons.csproj index 72a1294..c0cd0c4 100644 --- a/docker/crupest-api/CrupestApi/CrupestApi.Commons/CrupestApi.Commons.csproj +++ b/docker/crupest-api/CrupestApi/CrupestApi.Commons/CrupestApi.Commons.csproj @@ -2,6 +2,7 @@ <PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
+ <TargetType>library</TargetType>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
diff --git a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Json.cs b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Json.cs index 0ec3ff0..8409a96 100644 --- a/docker/crupest-api/CrupestApi/CrupestApi.Commons/Json.cs +++ b/docker/crupest-api/CrupestApi/CrupestApi.Commons/Json.cs @@ -1,9 +1,8 @@ -using System.Text; using System.Text.Json; +using Microsoft.Extensions.Options; namespace CrupestApi.Commons; - public static class CrupestApiJsonExtensions { public static IServiceCollection AddJsonOptions(this IServiceCollection services) @@ -22,8 +21,8 @@ public static class CrupestApiJsonExtensions public static async Task WriteJsonAsync<T>(this HttpResponse response, T bodyObject, int statusCode = 200, HttpResponseAction? beforeWriteBody = null, CancellationToken cancellationToken = default) { - var jsonOptions = response.HttpContext.RequestServices.GetRequiredService<JsonSerializerOptions>(); - byte[] json = JsonSerializer.SerializeToUtf8Bytes<T>(bodyObject, jsonOptions); + var jsonOptions = response.HttpContext.RequestServices.GetRequiredService<IOptionsSnapshot<JsonSerializerOptions>>(); + byte[] json = JsonSerializer.SerializeToUtf8Bytes<T>(bodyObject, jsonOptions.Value); var byteCount = json.Length; response.StatusCode = statusCode; diff --git a/docker/crupest-api/CrupestApi/CrupestApi.Files/CrupestApi.Files.csproj b/docker/crupest-api/CrupestApi/CrupestApi.Files/CrupestApi.Files.csproj index 2d78adb..bb98ece 100644 --- a/docker/crupest-api/CrupestApi/CrupestApi.Files/CrupestApi.Files.csproj +++ b/docker/crupest-api/CrupestApi/CrupestApi.Files/CrupestApi.Files.csproj @@ -1,11 +1,12 @@ <Project Sdk="Microsoft.NET.Sdk.Web">
- <ItemGroup> - <ProjectReference Include="..\CrupestApi.Commons\CrupestApi.Commons.csproj" /> + <ItemGroup>
+ <ProjectReference Include="..\CrupestApi.Commons\CrupestApi.Commons.csproj" />
</ItemGroup>
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
+ <TargetType>library</TargetType>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
diff --git a/docker/crupest-api/CrupestApi/CrupestApi.Secrets/CrupestApi.Secrets.csproj b/docker/crupest-api/CrupestApi/CrupestApi.Secrets/CrupestApi.Secrets.csproj index 2d78adb..bb98ece 100644 --- a/docker/crupest-api/CrupestApi/CrupestApi.Secrets/CrupestApi.Secrets.csproj +++ b/docker/crupest-api/CrupestApi/CrupestApi.Secrets/CrupestApi.Secrets.csproj @@ -1,11 +1,12 @@ <Project Sdk="Microsoft.NET.Sdk.Web">
- <ItemGroup> - <ProjectReference Include="..\CrupestApi.Commons\CrupestApi.Commons.csproj" /> + <ItemGroup>
+ <ProjectReference Include="..\CrupestApi.Commons\CrupestApi.Commons.csproj" />
</ItemGroup>
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
+ <TargetType>library</TargetType>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
diff --git a/docker/crupest-api/CrupestApi/CrupestApi.Todos/CrupestApi.Todos.csproj b/docker/crupest-api/CrupestApi/CrupestApi.Todos/CrupestApi.Todos.csproj index 2d78adb..bb98ece 100644 --- a/docker/crupest-api/CrupestApi/CrupestApi.Todos/CrupestApi.Todos.csproj +++ b/docker/crupest-api/CrupestApi/CrupestApi.Todos/CrupestApi.Todos.csproj @@ -1,11 +1,12 @@ <Project Sdk="Microsoft.NET.Sdk.Web">
- <ItemGroup> - <ProjectReference Include="..\CrupestApi.Commons\CrupestApi.Commons.csproj" /> + <ItemGroup>
+ <ProjectReference Include="..\CrupestApi.Commons\CrupestApi.Commons.csproj" />
</ItemGroup>
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
+ <TargetType>library</TargetType>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
diff --git a/docker/crupest-api/CrupestApi/CrupestApi/CrupestApi.csproj b/docker/crupest-api/CrupestApi/CrupestApi/CrupestApi.csproj index c408c7d..0ab7169 100644 --- a/docker/crupest-api/CrupestApi/CrupestApi/CrupestApi.csproj +++ b/docker/crupest-api/CrupestApi/CrupestApi/CrupestApi.csproj @@ -1,16 +1,17 @@ <Project Sdk="Microsoft.NET.Sdk.Web">
- <ItemGroup> - <ProjectReference Include="..\CrupestApi.Todos\CrupestApi.Todos.csproj" /> - <ProjectReference Include="..\CrupestApi.Files\CrupestApi.Files.csproj" /> - <ProjectReference Include="..\CrupestApi.Commons\CrupestApi.Commons.csproj" /> - <ProjectReference Include="..\CrupestApi.Secrets\CrupestApi.Secrets.csproj" /> + <ItemGroup>
+ <ProjectReference Include="..\CrupestApi.Todos\CrupestApi.Todos.csproj" />
+ <ProjectReference Include="..\CrupestApi.Files\CrupestApi.Files.csproj" />
+ <ProjectReference Include="..\CrupestApi.Commons\CrupestApi.Commons.csproj" />
+ <ProjectReference Include="..\CrupestApi.Secrets\CrupestApi.Secrets.csproj" />
</ItemGroup>
<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
+ <TargetType>exe</TargetType>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
-</Project>
+</Project>
\ No newline at end of file |