AspNetCore.Docs/aspnetcore/grpc/httpapi/Startup.cs

30 lines
617 B
C#

#region snippet_1
public void ConfigureServices(IServiceCollection services)
{
services.AddGrpc();
services.AddGrpcHttpApi();
services.AddSwaggerGen(c =>
{
c.SwaggerDoc("v1", new OpenApiInfo { Title = "My API", Version = "v1" });
});
services.AddGrpcSwagger();
}
public void Configure(IApplicationBuilder app)
{
app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
});
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapGrpcService<GreeterService>();
});
}
#endregion