22 lines
653 B
C#
22 lines
653 B
C#
|
[ApiController]
|
||
|
[Route("[controller]")]
|
||
|
public class GreetingController : ControllerBase
|
||
|
{
|
||
|
private ILoggerFactory _loggerFactory;
|
||
|
|
||
|
public GreetingController(ILoggerFactory loggerFactory)
|
||
|
{
|
||
|
_loggerFactory = loggerFactory;
|
||
|
}
|
||
|
|
||
|
[HttpGet]
|
||
|
public async Task<ActionResult<string>> Get(string name)
|
||
|
{
|
||
|
var channel = GrpcChannel.ForAddress("https://localhost:5001",
|
||
|
new GrpcChannelOptions { LoggerFactory = _loggerFactory });
|
||
|
var client = new Greeter.GreeterClient(channel);
|
||
|
|
||
|
var reply = await client.SayHelloAsync(new HelloRequest { Name = name });
|
||
|
return Ok(reply.Message);
|
||
|
}
|
||
|
}
|