From dd849aa878badbb872847bb8edfc8d4006e6b89c Mon Sep 17 00:00:00 2001 From: JBBianchi Date: Wed, 25 Sep 2024 16:44:51 +0200 Subject: [PATCH] fix(Core.Api): handled partition id containing / when requesting metadata Closes #66 --- .../Services/CloudStreamsCoreApiClient.CloudEvents.cs | 3 +-- .../Controllers/CloudEventPartitionsController.cs | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/core/CloudStreams.Core.Api.Client/Services/CloudStreamsCoreApiClient.CloudEvents.cs b/src/core/CloudStreams.Core.Api.Client/Services/CloudStreamsCoreApiClient.CloudEvents.cs index aadbfef0..8a4cf220 100644 --- a/src/core/CloudStreams.Core.Api.Client/Services/CloudStreamsCoreApiClient.CloudEvents.cs +++ b/src/core/CloudStreams.Core.Api.Client/Services/CloudStreamsCoreApiClient.CloudEvents.cs @@ -13,7 +13,6 @@ using Neuroglia; using Neuroglia.Eventing.CloudEvents; -using Neuroglia.Serialization; namespace CloudStreams.Core.Api.Client.Services; @@ -45,7 +44,7 @@ public partial class CloudStreamsCoreApiClient public virtual async Task GetPartitionMetadataAsync(CloudEventPartitionType type, string id, CancellationToken cancellationToken = default) { if (string.IsNullOrWhiteSpace(id)) throw new ArgumentNullException(nameof(id)); - using var request = await this.ProcessRequestAsync(new HttpRequestMessage(HttpMethod.Get, $"{CloudEventPartitionsApiPath}{type}/{id}"), cancellationToken).ConfigureAwait(false); + using var request = await this.ProcessRequestAsync(new HttpRequestMessage(HttpMethod.Get, $"{CloudEventPartitionsApiPath}{type}/byId?id={Uri.EscapeDataString(id)}"), cancellationToken).ConfigureAwait(false); using var response = await this.ProcessResponseAsync(await this.HttpClient.SendAsync(request, cancellationToken).ConfigureAwait(false), cancellationToken).ConfigureAwait(false); var json = await response.Content.ReadAsStringAsync(cancellationToken).ConfigureAwait(false); return this.Serializer.Deserialize(json); diff --git a/src/core/CloudStreams.Core.Api/Controllers/CloudEventPartitionsController.cs b/src/core/CloudStreams.Core.Api/Controllers/CloudEventPartitionsController.cs index 29ed4973..92878b46 100644 --- a/src/core/CloudStreams.Core.Api/Controllers/CloudEventPartitionsController.cs +++ b/src/core/CloudStreams.Core.Api/Controllers/CloudEventPartitionsController.cs @@ -46,10 +46,10 @@ public virtual async Task ListPartitionsByType(CloudEventPartitio /// The id of the partition to get the metadata of /// A /// A new - [HttpGet("{type}/{id}")] + [HttpGet("{type}/byId")] [ProducesResponseType(typeof(PartitionMetadata), (int)HttpStatusCode.OK)] [ProducesResponseType(typeof(Neuroglia.ProblemDetails), (int)HttpStatusCode.BadRequest)] - public virtual async Task GetPartitionMetadata(CloudEventPartitionType type, string id, CancellationToken cancellationToken) + public virtual async Task GetPartitionMetadata(CloudEventPartitionType type, [FromQuery]string id, CancellationToken cancellationToken) { if (!this.ModelState.IsValid) return this.ValidationProblem(this.ModelState); return this.Process(await this.Mediator.ExecuteAsync(new GetEventPartitionMetadataQuery(new(type, id)), cancellationToken).ConfigureAwait(false));