Edition 0 Updated to asp. Net core 0


Sample microservices/containers to reroute through the API Gateways



Yüklə 11,82 Mb.
Pdf görüntüsü
səhifə150/288
tarix12.07.2023
ölçüsü11,82 Mb.
#136458
1   ...   146   147   148   149   150   151   152   153   ...   288
NET-Microservices-Architecture-for-Containerized-NET-Applications

Sample microservices/containers to reroute through the API Gateways 
As an example, eShopOnContainers has around six internal microservice-types that have to be 
published through the API Gateways, as shown in the following image. 
Figure 6-29. Microservice folders in eShopOnContainers solution in Visual Studio 
About the Identity service, in the design it’s left out of the API Gateway routing because it’s the only 
cross-
cutting concern in the system, although with Ocelot it’s also possible to include it as part of the 
rerouting lists. 
All those services are currently implemented as ASP.NET Core Web API services, as you can tell from 
the code. Let’s focus on one of the microservices like the Catalog microservice code.
Figure 6-30. Sample Web API microservice (Catalog microservice) 


166 
CHAPTER 5 | Designing and Developing Multi-Container and Microservice-Based .NET Applications 
You can see that the Catalog microservice is a typical ASP.NET Core Web API project with several 
controllers and methods like in the following code. 
[HttpGet] 
[
Route
(
"items/{id:int}"
)] 
[
ProducesResponseType
((
int
)HttpStatusCode.
BadRequest
)] 
[
ProducesResponseType
((
int
)HttpStatusCode.
NotFound
)] 
[
ProducesResponseType
(
typeof
(CatalogItem),(
int
)HttpStatusCode.
OK
)] 
public
async Task 
GetItemById
(
int
id) 

if
(id <= 
0


return
BadRequest
(); 

var
item = await _catalogContext.
CatalogItems

SingleOrDefaultAsync
(ci => ci.
Id
== id); 
//…

Yüklə 11,82 Mb.

Dostları ilə paylaş:
1   ...   146   147   148   149   150   151   152   153   ...   288




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©azkurs.org 2024
rəhbərliyinə müraciət

gir | qeydiyyatdan keç
    Ana səhifə


yükləyin