using Dapr.Client; using Microsoft.AspNetCore.Mvc; namespace MyBackEnd.Controllers { [ApiController] [Route("[controller]")] public class WeatherForecastController : ControllerBase { private static readonly string[] Summaries = new[] { "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" }; private readonly DaprClient _daprClient; private readonly ILogger _logger; public WeatherForecastController( DaprClient daprClient, ILogger logger) { _daprClient = daprClient; _logger = logger; } [HttpGet(Name = "GetWeatherForecast")] public IEnumerable Get() { return Enumerable.Range(1, 5).Select(index => new WeatherForecast { Date = DateOnly.FromDateTime(DateTime.Now.AddDays(index)), TemperatureC = Random.Shared.Next(-20, 55), Summary = Summaries[Random.Shared.Next(Summaries.Length)] }) .ToArray(); } [HttpGet("remote-time")] public async Task GetTime() { var r = await _daprClient.InvokeMethodAsync( HttpMethod.Get, "hotline", "api/v1/Test/time", HttpContext.RequestAborted); return r.Result; } } public class Rsp { //{ // "result": "Wednesday, 19 July 2023 14:32:43", // "code": 0, // "message": null, // "error": null //} public string Result { get; set; } public int Code { get; set; } public string Message { get; set; } public string Error { get; set; } } }