Skip to content

Commit

Permalink
fix(Core.Api): handled partition id containing / when requesting meta…
Browse files Browse the repository at this point in the history
…data

Closes #66
  • Loading branch information
JBBianchi committed Sep 25, 2024
1 parent 654ef2b commit dd849aa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

using Neuroglia;
using Neuroglia.Eventing.CloudEvents;
using Neuroglia.Serialization;

namespace CloudStreams.Core.Api.Client.Services;

Expand Down Expand Up @@ -45,7 +44,7 @@ public partial class CloudStreamsCoreApiClient
public virtual async Task<PartitionMetadata?> 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<PartitionMetadata>(json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ public virtual async Task<IActionResult> ListPartitionsByType(CloudEventPartitio
/// <param name="id">The id of the partition to get the metadata of</param>
/// <param name="cancellationToken">A <see cref="CancellationToken"/></param>
/// <returns>A new <see cref="IActionResult"/></returns>
[HttpGet("{type}/{id}")]
[HttpGet("{type}/byId")]
[ProducesResponseType(typeof(PartitionMetadata), (int)HttpStatusCode.OK)]
[ProducesResponseType(typeof(Neuroglia.ProblemDetails), (int)HttpStatusCode.BadRequest)]
public virtual async Task<IActionResult> GetPartitionMetadata(CloudEventPartitionType type, string id, CancellationToken cancellationToken)
public virtual async Task<IActionResult> 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));
Expand Down

0 comments on commit dd849aa

Please sign in to comment.