небольшая добавка чтоб понять что происходит вообще...
This commit is contained in:
parent
54e0f8d8f3
commit
54157ec2bf
@ -22,7 +22,7 @@ public class RestaurantController : ControllerBase
|
|||||||
[HttpGet("{id}")]
|
[HttpGet("{id}")]
|
||||||
public async Task<ActionResult<Restaurant?>> GetOne(Guid id) {
|
public async Task<ActionResult<Restaurant?>> GetOne(Guid id) {
|
||||||
var restaurant = await _context.Restaurants.FindAsync(id);
|
var restaurant = await _context.Restaurants.FindAsync(id);
|
||||||
if (restaurant == null) return NotFound();
|
if (restaurant == null) return NotFound($"Restourant with [id: '{id}'] not found");
|
||||||
var waiters = await WaiterApiClient.GetAllForRestaurant(id);
|
var waiters = await WaiterApiClient.GetAllForRestaurant(id);
|
||||||
restaurant.Waiters = waiters;
|
restaurant.Waiters = waiters;
|
||||||
return restaurant;
|
return restaurant;
|
||||||
|
28
balakhonov_danila_lab_3/ApiRestaurant/NetworkSupport.cs
Normal file
28
balakhonov_danila_lab_3/ApiRestaurant/NetworkSupport.cs
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
namespace ApiRestaurant;
|
||||||
|
|
||||||
|
public static class NetworkSupport
|
||||||
|
{
|
||||||
|
public static async Task CheckConnectionAsync(string address)
|
||||||
|
{
|
||||||
|
using (var client = new HttpClient())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var response = await client.GetAsync(address);
|
||||||
|
|
||||||
|
if (response.IsSuccessStatusCode)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Соединение успешно проверено. Статус-код: {response.StatusCode}");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Соединение не удалось проверить. Статус-код: {response.StatusCode}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (HttpRequestException ex)
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Ошибка при проверке соединения: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -8,6 +8,7 @@ var waiterApiAddress =
|
|||||||
Environment.GetEnvironmentVariable("WAITER_API_URL")
|
Environment.GetEnvironmentVariable("WAITER_API_URL")
|
||||||
?? "http://localhost:4000/waiters/";
|
?? "http://localhost:4000/waiters/";
|
||||||
WaiterApiClient.Setup(waiterApiAddress);
|
WaiterApiClient.Setup(waiterApiAddress);
|
||||||
|
await NetworkSupport.CheckConnectionAsync(waiterApiAddress);
|
||||||
|
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
builder.Services.AddControllers();
|
builder.Services.AddControllers();
|
||||||
|
@ -2,7 +2,7 @@ services:
|
|||||||
restaurant_service:
|
restaurant_service:
|
||||||
build: ./ApiRestaurant/
|
build: ./ApiRestaurant/
|
||||||
environment:
|
environment:
|
||||||
WAITER_API_URL: http://localhost:80/waiters/
|
WAITER_API_URL: http://waiter_service:4000/waiters/
|
||||||
expose:
|
expose:
|
||||||
- 8080
|
- 8080
|
||||||
depends_on:
|
depends_on:
|
||||||
|
Loading…
Reference in New Issue
Block a user