Merge branch 'master' of https://bitbucket.org/Hauth/shogi
This commit is contained in:
@@ -29,7 +29,7 @@
|
|||||||
<PackageReference Include="FluentValidation" Version="11.9.0" />
|
<PackageReference Include="FluentValidation" Version="11.9.0" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.1" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.1" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.1" />
|
<PackageReference Include="Microsoft.AspNetCore.Authentication.OpenIdConnect" Version="8.0.1" />
|
||||||
<PackageReference Include="Microsoft.Identity.Web" Version="2.16.1" />
|
<PackageReference Include="Microsoft.Identity.Web" Version="2.17.0" />
|
||||||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
|
||||||
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
|
<PackageReference Include="System.Data.SqlClient" Version="4.8.6" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|||||||
@@ -16,13 +16,16 @@ namespace Shogi.UI.Pages.Home.Api
|
|||||||
private readonly AccountState accountState;
|
private readonly AccountState accountState;
|
||||||
private readonly HttpClient guestHttpClient;
|
private readonly HttpClient guestHttpClient;
|
||||||
private readonly HttpClient msalHttpClient;
|
private readonly HttpClient msalHttpClient;
|
||||||
|
private readonly string baseUrl;
|
||||||
|
|
||||||
public ShogiApi(IHttpClientFactory clientFactory, AccountState accountState)
|
public ShogiApi(IHttpClientFactory clientFactory, AccountState accountState, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
this.serializerOptions = new JsonSerializerOptions(JsonSerializerDefaults.Web);
|
this.serializerOptions = new JsonSerializerOptions(JsonSerializerDefaults.Web);
|
||||||
this.accountState = accountState;
|
this.accountState = accountState;
|
||||||
this.guestHttpClient = clientFactory.CreateClient(GuestClientName);
|
this.guestHttpClient = clientFactory.CreateClient(GuestClientName);
|
||||||
this.msalHttpClient = clientFactory.CreateClient(MsalClientName);
|
this.msalHttpClient = clientFactory.CreateClient(MsalClientName);
|
||||||
|
this.baseUrl = configuration["ShogiApiUrl"] ?? throw new InvalidOperationException("Configuration missing.");
|
||||||
|
this.baseUrl = this.baseUrl.TrimEnd('/');
|
||||||
}
|
}
|
||||||
|
|
||||||
private HttpClient HttpClient => accountState.User?.WhichAccountPlatform switch
|
private HttpClient HttpClient => accountState.User?.WhichAccountPlatform switch
|
||||||
@@ -40,7 +43,7 @@ namespace Shogi.UI.Pages.Home.Api
|
|||||||
|
|
||||||
public async Task<Session?> GetSession(string name)
|
public async Task<Session?> GetSession(string name)
|
||||||
{
|
{
|
||||||
var response = await HttpClient.GetAsync(new Uri($"Sessions/{name}", UriKind.Relative));
|
var response = await HttpClient.GetAsync(RelativeUri($"Sessions/{name}"));
|
||||||
if (response.IsSuccessStatusCode)
|
if (response.IsSuccessStatusCode)
|
||||||
{
|
{
|
||||||
return (await response.Content.ReadFromJsonAsync<ReadSessionResponse>(serializerOptions))?.Session;
|
return (await response.Content.ReadFromJsonAsync<ReadSessionResponse>(serializerOptions))?.Session;
|
||||||
@@ -98,6 +101,6 @@ namespace Shogi.UI.Pages.Home.Api
|
|||||||
return HttpClient.PatchAsync(RelativeUri($"Sessions/{name}/Join"), null);
|
return HttpClient.PatchAsync(RelativeUri($"Sessions/{name}/Join"), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Uri RelativeUri(string path) => new(path, UriKind.Relative);
|
private Uri RelativeUri(string path) => new($"{this.baseUrl}/{path}", UriKind.Absolute);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@
|
|||||||
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="8.0.0" />
|
||||||
<PackageReference Include="Microsoft.Identity.Client" Version="4.59.0" />
|
<PackageReference Include="Microsoft.Identity.Client" Version="4.59.0" />
|
||||||
<PackageReference Include="Microsoft.Net.Http.Headers" Version="8.0.1" />
|
<PackageReference Include="Microsoft.Net.Http.Headers" Version="8.0.1" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
|
||||||
<PackageReference Include="xunit" Version="2.6.6" />
|
<PackageReference Include="xunit" Version="2.6.6" />
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
|||||||
@@ -9,11 +9,11 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
|
||||||
<PackageReference Include="Microsoft.Playwright.NUnit" Version="1.41.1" />
|
<PackageReference Include="Microsoft.Playwright.NUnit" Version="1.41.2" />
|
||||||
<PackageReference Include="NUnit" Version="4.0.1" />
|
<PackageReference Include="NUnit" Version="4.0.1" />
|
||||||
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
|
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
|
||||||
<PackageReference Include="NUnit.Analyzers" Version="3.10.0">
|
<PackageReference Include="NUnit.Analyzers" Version="4.0.1">
|
||||||
<PrivateAssets>all</PrivateAssets>
|
<PrivateAssets>all</PrivateAssets>
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="FluentAssertions" Version="6.12.0" />
|
<PackageReference Include="FluentAssertions" Version="6.12.0" />
|
||||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
|
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
|
||||||
<PackageReference Include="xunit" Version="2.6.6" />
|
<PackageReference Include="xunit" Version="2.6.6" />
|
||||||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
|
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6">
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
|
|||||||
Reference in New Issue
Block a user