diff --git a/.github/workflows/prerelease.yml b/.github/workflows/prerelease.yml index f5d8773..cc3d8ee 100644 --- a/.github/workflows/prerelease.yml +++ b/.github/workflows/prerelease.yml @@ -15,7 +15,7 @@ jobs: publish: env: CONFIGURATION: 'Release' - DOTNET_VERSION: '8.0' + DOTNET_VERSION: '9.0' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9f43874..b89179c 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,7 +10,7 @@ jobs: publish: env: CONFIGURATION: 'Release' - DOTNET_VERSION: '8.0' + DOTNET_VERSION: '9.0' runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 diff --git a/CHANGELOG.md b/CHANGELOG.md index f6c2c77..011e04a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,4 +18,11 @@ ### 🐛 Bug Fixes -- Fixed a bug where the entire query string was encoded instead of only the query parameter keys and values. \ No newline at end of file +- Fixed a bug where the entire query string was encoded instead of only the query parameter keys and values. + +## 2.0.3 + +### 🛠 Technical + +- Fixed HttpClientFactory usage in default request sender +- Migrate to SLNX diff --git a/NotoriousClient.Sample/Program.cs b/NotoriousClient.Sample/Program.cs index 4bcdfbe..7adedbd 100644 --- a/NotoriousClient.Sample/Program.cs +++ b/NotoriousClient.Sample/Program.cs @@ -1,10 +1,9 @@ // See https://aka.ms/new-console-template for more information using Microsoft.Extensions.DependencyInjection; + using NotoriousClient.Builder; -using NotoriousClient.Builder.Authentication; using NotoriousClient.Clients; -using NotoriousClient.Converters; using NotoriousClient.Sender; Console.WriteLine("Hello, World!"); @@ -25,6 +24,7 @@ services.AddHttpClient(); services.AddScoped((serviceProvider) => new RequestSender(serviceProvider.GetRequiredService())); + services.AddScoped((serviceProvider) => new UserClient(serviceProvider.GetRequiredService(), "http://my.api.com/")); ServiceProvider provider = services.BuildServiceProvider(); @@ -94,7 +94,7 @@ public TotoBuilder(string url, string route, Method method) : base(url, route, m public override HttpRequestMessage Build() { - HttpRequestMessage request = base.Build(); + HttpRequestMessage request = base.Build(); request.Headers.Add("TOTO", toto); return request; } diff --git a/NotoriousClient.sln b/NotoriousClient.sln deleted file mode 100644 index feadff6..0000000 --- a/NotoriousClient.sln +++ /dev/null @@ -1,50 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.4.33110.190 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NotoriousClient", "NotoriousClient\NotoriousClient.csproj", "{D0C70B6B-E6F3-4254-AC1B-BC523426E2A3}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NotoriousClient.Sample", "NotoriousClient.Sample\NotoriousClient.Sample.csproj", "{B8A79A34-8CAE-4486-865B-956A633768E7}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NotoriousClient.Tests.Unit", "NotoriousClient.Tests.Unit\NotoriousClient.Tests.Unit.csproj", "{8F832E05-5A6C-4289-AB1E-2CD644E521DF}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "CI", "CI", "{02EA681E-C7D8-13C7-8484-4AC65E1B71E8}" - ProjectSection(SolutionItems) = preProject - .github\workflows\prerelease.yml = .github\workflows\prerelease.yml - .github\workflows\release.yml = .github\workflows\release.yml - EndProjectSection -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Docs", "Docs", "{152A5ABF-D4EA-4E4E-B0C8-86791981137B}" - ProjectSection(SolutionItems) = preProject - CHANGELOG.md = CHANGELOG.md - LICENSE.txt = LICENSE.txt - README.md = README.md - EndProjectSection -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {D0C70B6B-E6F3-4254-AC1B-BC523426E2A3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D0C70B6B-E6F3-4254-AC1B-BC523426E2A3}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D0C70B6B-E6F3-4254-AC1B-BC523426E2A3}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D0C70B6B-E6F3-4254-AC1B-BC523426E2A3}.Release|Any CPU.Build.0 = Release|Any CPU - {B8A79A34-8CAE-4486-865B-956A633768E7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B8A79A34-8CAE-4486-865B-956A633768E7}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B8A79A34-8CAE-4486-865B-956A633768E7}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B8A79A34-8CAE-4486-865B-956A633768E7}.Release|Any CPU.Build.0 = Release|Any CPU - {8F832E05-5A6C-4289-AB1E-2CD644E521DF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {8F832E05-5A6C-4289-AB1E-2CD644E521DF}.Debug|Any CPU.Build.0 = Debug|Any CPU - {8F832E05-5A6C-4289-AB1E-2CD644E521DF}.Release|Any CPU.ActiveCfg = Release|Any CPU - {8F832E05-5A6C-4289-AB1E-2CD644E521DF}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {02848B99-CEFB-46C3-A1D7-4251CB0B989F} - EndGlobalSection -EndGlobal diff --git a/NotoriousClient.slnx b/NotoriousClient.slnx new file mode 100644 index 0000000..0d753f0 --- /dev/null +++ b/NotoriousClient.slnx @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/NotoriousClient/NotoriousClient.csproj b/NotoriousClient/NotoriousClient.csproj index 1e1c83a..3fffd8b 100644 --- a/NotoriousClient/NotoriousClient.csproj +++ b/NotoriousClient/NotoriousClient.csproj @@ -5,7 +5,7 @@ NotoriousClient enable enable - 2.0.2 + 2.0.3 README.md Brice SCHUMACHER https://github.com/Notorious-Coding/Notorious-Client/ diff --git a/NotoriousClient/Sender/RequestSender.cs b/NotoriousClient/Sender/RequestSender.cs index cf32ae7..a90d558 100644 --- a/NotoriousClient/Sender/RequestSender.cs +++ b/NotoriousClient/Sender/RequestSender.cs @@ -5,7 +5,7 @@ /// public class RequestSender : IRequestSender { - private readonly HttpClient _client; + private readonly IHttpClientFactory _factory; /// /// Initialize a new instance of . @@ -15,13 +15,13 @@ public class RequestSender : IRequestSender public RequestSender(IHttpClientFactory factory) { ArgumentNullException.ThrowIfNull(factory, nameof(factory)); - _client = factory.CreateClient(); + _factory = factory; } /// public async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken = default) { - HttpResponseMessage response = await _client.SendAsync(request, cancellationToken); + HttpResponseMessage response = await _factory.CreateClient().SendAsync(request, cancellationToken); return response; } @@ -29,7 +29,7 @@ public async Task SendAsync(HttpRequestMessage request, Can /// public HttpResponseMessage Send(HttpRequestMessage request) { - return _client.Send(request); + return _factory.CreateClient().Send(request); } } }