Skip to content

Commit e3c0b9e

Browse files
committed
add versioning for settings-service #5
1 parent cdfb5b3 commit e3c0b9e

File tree

5 files changed

+36
-24
lines changed

5 files changed

+36
-24
lines changed

restclient.http

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ content-type: {{contentType}}
1212

1313
###
1414
@country-id = 18a4a8ae-3338-484a-a4ed-6e64d13d84dc
15-
GET {{host}}/setting-api/countries/{{country-id}} HTTP/1.1
15+
GET {{host}}/setting-api/v1/countries/{{country-id}} HTTP/1.1
1616
content-type: {{contentType}}
1717

1818
###

src/BuildingBlocks/CoolStore.AppContracts/RestApi/ICountryApi.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace CoolStore.AppContracts.RestApi
88
{
99
public interface ICountryApi
1010
{
11-
[Get("api/countries/{countryId}")]
11+
[Get("api/v1/countries/{countryId}")]
1212
Task<ResultModel<CountryDto>> GetCountryByIdAsync([Path] Guid countryId);
1313
}
1414
}
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
using System.Threading;
2+
using System.Threading.Tasks;
3+
using CoolStore.AppContracts.IntegrationEvents;
4+
using Dapr;
5+
using Microsoft.AspNetCore.Mvc;
6+
using N8T.Infrastructure.Endpoint;
7+
8+
namespace ProductService.Application.V1.Endpoints.IntegrationEvents
9+
{
10+
[ApiVersionNeutral]
11+
[ApiExplorerSettings(IgnoreApi = true)]
12+
[Route("api/v1/[controller]")]
13+
public class CustomerCreated : BaseAsyncEndpoint.WithRequest<CustomerCreatedIntegrationEvent>.WithoutResponse
14+
{
15+
// [HttpPost("CustomerCreated")]
16+
// [Topic("pubsub", "CustomerCreatedIntegrationEvent")]
17+
// public override async Task HandleAsync(CustomerCreatedIntegrationEvent @event)
18+
// {
19+
// // TODO: this is an example for pub/sub
20+
// }
21+
22+
[HttpPost("CustomerCreated")]
23+
[Topic("pubsub", "CustomerCreatedIntegrationEvent")]
24+
public override async Task<ActionResult> HandleAsync(CustomerCreatedIntegrationEvent @event,
25+
CancellationToken cancellationToken = new ())
26+
{
27+
// TODO: this is an example for pub/sub
28+
return Ok();
29+
}
30+
}
31+
}

src/Product/ProductService.Application/V1/Endpoints/IntegrationEvents/CustomerCreatedIntegrationEvent.cs

Lines changed: 0 additions & 20 deletions
This file was deleted.

src/Setting/SettingService.Application/Endpoints/Queries/GetCountryById.cs renamed to src/Setting/SettingService.Application/Endpoints/V1/Queries/GetCountryById.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,12 @@
1111
using N8T.Infrastructure.Endpoint;
1212
using SettingService.Core.Entities;
1313

14-
namespace SettingService.Application.Endpoints.Queries
14+
namespace SettingService.Application.Endpoints.V1.Queries
1515
{
1616
public class GetCountryById : BaseAsyncEndpoint.WithRequest<Guid>.WithResponse<CountryDto>
1717
{
18-
[HttpGet("/api/countries/{id:guid}")]
18+
[ApiVersion( "1.0" )]
19+
[HttpGet("/api/v{version:apiVersion}/countries/{id:guid}")]
1920
public override async Task<ActionResult<CountryDto>> HandleAsync(Guid id,
2021
CancellationToken cancellationToken = new())
2122
{

0 commit comments

Comments
 (0)