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);
//…
Dostları ilə paylaş: