From ec6f0ea792a70eaa7d07d81f4993efb9b9583327 Mon Sep 17 00:00:00 2001 From: TheR00st3r Date: Fri, 3 Nov 2023 23:09:44 +0100 Subject: [PATCH] Update Urls / --- PugSharp.ApiStats/ApiStats.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/PugSharp.ApiStats/ApiStats.cs b/PugSharp.ApiStats/ApiStats.cs index 0a21af20..90a5cb37 100644 --- a/PugSharp.ApiStats/ApiStats.cs +++ b/PugSharp.ApiStats/ApiStats.cs @@ -15,6 +15,12 @@ public class ApiStats : IDisposable public ApiStats(string apiStatsUrl, string apiStatsKey) { _Logger.LogInformation("Create Api Stats with BaseUrl: {url}", apiStatsUrl); + + if (!apiStatsUrl.EndsWith('/')) + { + apiStatsUrl += "/"; + } + _HttpClient = new HttpClient() { BaseAddress = new Uri(apiStatsUrl), @@ -30,7 +36,7 @@ public async Task SendGoingLiveAsync(GoingLiveParams goingLiveParams, Cancellati {ApiStatsConstants.StatsMapName, goingLiveParams.MapName} }; - var uri = QueryHelpers.AddQueryString($"/golive/{goingLiveParams.MapNumber}", queryParams); + var uri = QueryHelpers.AddQueryString($"golive/{goingLiveParams.MapNumber}", queryParams); var response = await _HttpClient.PostAsync(uri, null, cancellationToken).ConfigureAwait(false); @@ -46,7 +52,7 @@ public async Task SendMapResultAsync(MapResultParams mapResultParams, Cancellati {ApiStatsConstants.StatsMapWinner, mapResultParams.WinnerTeamName} }; - var uri = QueryHelpers.AddQueryString($"/finalize/{mapResultParams.MapNumber}", queryParams); + var uri = QueryHelpers.AddQueryString($"finalize/{mapResultParams.MapNumber}", queryParams); var response = await _HttpClient.PostAsync(uri, null, cancellationToken).ConfigureAwait(false); @@ -61,7 +67,7 @@ public async Task SendRoundStatsUpdateAsync(RoundStatusUpdateParams roundStatusU {"team2score", CreateIntParam(roundStatusUpdateParams.CurrentMap.Team2.Score)}, }; - var uri = QueryHelpers.AddQueryString($"/updateround/{roundStatusUpdateParams.MapNumber}", queryParams); + var uri = QueryHelpers.AddQueryString($"updateround/{roundStatusUpdateParams.MapNumber}", queryParams); var response = await _HttpClient.PostAsync(uri, null, cancellationToken).ConfigureAwait(false); @@ -127,7 +133,7 @@ private async Task UpdatePlayerStatsInternalAsync(int mapNumber, TeamInfo teamIn {ApiStatsConstants.StatsMvp, CreateIntParam(playerStatistics.Mvp)}, }; - var uri = QueryHelpers.AddQueryString($"/updateplayer/{mapNumber}", queryParams); + var uri = QueryHelpers.AddQueryString($"updateplayer/{mapNumber}", queryParams); var response = await _HttpClient.PostAsync(uri, null, cancellationToken).ConfigureAwait(false); @@ -149,7 +155,7 @@ public async Task SendSeriesResultAsync(SeriesResultParams seriesResultParams, C {ApiStatsConstants.StatsSeriesForfeit, CreateIntParam(Convert.ToInt32(seriesResultParams.Forfeit))}, }; - var uri = QueryHelpers.AddQueryString($"/finalize", queryParams); + var uri = QueryHelpers.AddQueryString($"finalize", queryParams); var response = await _HttpClient.PostAsync(uri, null, cancellationToken).ConfigureAwait(false); @@ -163,7 +169,7 @@ public async Task SendSeriesResultAsync(SeriesResultParams seriesResultParams, C internal async Task SendFreeServerInternalAsync(CancellationToken cancellationToken) { - var response = await _HttpClient.PostAsync(new Uri("/freeserver"), null, cancellationToken).ConfigureAwait(false); + var response = await _HttpClient.PostAsync(new Uri("freeserver"), null, cancellationToken).ConfigureAwait(false); await HandleResponseAsync(response, cancellationToken).ConfigureAwait(false); }