mirror of https://github.com/dapr/dotnet-sdk.git
56 lines
1.6 KiB
C#
56 lines
1.6 KiB
C#
// ------------------------------------------------------------
|
|
// Copyright (c) Microsoft Corporation.
|
|
// Licensed under the MIT License.
|
|
// ------------------------------------------------------------
|
|
|
|
using Microsoft.AspNetCore.Builder;
|
|
using Microsoft.AspNetCore.Hosting;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Microsoft.Extensions.Hosting;
|
|
|
|
namespace GrpcServiceSample
|
|
{
|
|
/// <summary>
|
|
/// Startup class.
|
|
/// </summary>
|
|
public class Startup
|
|
{
|
|
/// <summary>
|
|
/// Configure Services
|
|
/// </summary>
|
|
/// <param name="services"></param>
|
|
public void ConfigureServices(IServiceCollection services)
|
|
{
|
|
services.AddGrpc();
|
|
|
|
services.AddDaprClient();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Configure app
|
|
/// </summary>
|
|
/// <param name="app"></param>
|
|
/// <param name="env"></param>
|
|
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
|
{
|
|
if (env.IsDevelopment())
|
|
{
|
|
app.UseDeveloperExceptionPage();
|
|
}
|
|
|
|
app.UseRouting();
|
|
|
|
app.UseEndpoints(endpoints =>
|
|
{
|
|
endpoints.MapGrpcService<BankingService>();
|
|
|
|
endpoints.MapGet("/", async context =>
|
|
{
|
|
await context.Response.WriteAsync("Communication with gRPC endpoints must be made through a gRPC client. To learn how to create a client, visit: https://go.microsoft.com/fwlink/?linkid=2086909");
|
|
});
|
|
});
|
|
}
|
|
}
|
|
}
|