Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

update readme #2183

Merged
merged 1 commit into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 16 additions & 25 deletions src/Grpc.AspNetCore.Server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,30 @@

## Configure gRPC

In *Startup.cs*:
In *Program.cs*:

* gRPC is enabled with the `AddGrpc` method.
* Each gRPC service is added to the routing pipeline through the `MapGrpcService` method. For information about how to create gRPC services, see [Create gRPC services and methods](https://docs.microsoft.com/aspnet/core/grpc/services).
* Each gRPC service is added to the routing pipeline through the `MapGrpcService` method. For information about how to create gRPC services, see [Create gRPC services and methods](https://learn.microsoft.com/aspnet/core/grpc/services).

```csharp
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddGrpc();
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}

app.UseRouting();

app.UseEndpoints(endpoints =>
{
endpoints.MapGrpcService<GreeterService>();
});
}
}
using GrpcGreeter.Services;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddGrpc();

var app = builder.Build();

// Configure the HTTP request pipeline.
app.MapGrpcService<GreeterService>();

app.Run();
```

ASP.NET Core middleware and features share the routing pipeline, therefore an app can be configured to serve additional request handlers. The additional request handlers, such as MVC controllers, work in parallel with the configured gRPC services.

## Links

* [Documentation](https://docs.microsoft.com/aspnet/core/grpc/aspnetcore)
* [Documentation](https://learn.microsoft.com/aspnet/core/grpc/aspnetcore)
* [grpc-dotnet GitHub](https://github.com/grpc/grpc-dotnet)
43 changes: 21 additions & 22 deletions src/Grpc.AspNetCore.Web/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,32 @@

Grpc.AspNetCore.Web provides middleware that enables ASP.NET Core gRPC services to accept gRPC-Web calls.

In *Startup.cs*:
## Configure gRPC-Web

In *Program.cs*:

```csharp
public void ConfigureServices(IServiceCollection services)
{
services.AddGrpc();
services.AddGrpcWeb(o => o.GrpcWebEnabled = true);
}

public void Configure(IApplicationBuilder app)
{
app.UseRouting();
app.UseGrpcWeb();
app.UseEndpoints(endpoints =>
{
endpoints.MapGrpcService<GreeterService>();
});
}
using GrpcGreeter.Services;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddGrpc();

var app = builder.Build();

// Configure the HTTP request pipeline.
app.UseRouting();
app.UseGrpcWeb(new GrpcWebOptions { DefaultEnabled = true });
app.MapGrpcService<GreeterService>();

app.Run();
```

gRPC-Web can be enabled for all gRPC services by setting `GrpcWebOptions.GrpcWebEnabled = true`, or enabled on individual services with `EnableGrpcWeb()`:
gRPC-Web can be enabled for all gRPC services by setting `GrpcWebOptions.DefaultEnabled = true`, or enabled on individual services with `EnableGrpcWeb()`:

```csharp
app.UseEndpoints(endpoints =>
{
endpoints.MapGrpcService<GreeterService>().EnableGrpcWeb();
});
app.MapGrpcService<GreeterService>().EnableGrpcWeb();
```

### gRPC-Web and streaming
Expand All @@ -43,5 +42,5 @@ When using gRPC-Web, we only recommend the use of unary methods and server strea

## Links

* [Documentation](https://docs.microsoft.com/aspnet/core/grpc/browser)
* [Documentation](https://learn.microsoft.com/aspnet/core/grpc/browser)
* [grpc-dotnet GitHub](https://github.com/grpc/grpc-dotnet)
41 changes: 16 additions & 25 deletions src/Grpc.AspNetCore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,39 +8,30 @@

## Configure gRPC

In *Startup.cs*:
In *Program.cs*:

* gRPC is enabled with the `AddGrpc` method.
* Each gRPC service is added to the routing pipeline through the `MapGrpcService` method. For information about how to create gRPC services, see [Create gRPC services and methods](https://docs.microsoft.com/aspnet/core/grpc/services).
* Each gRPC service is added to the routing pipeline through the `MapGrpcService` method. For information about how to create gRPC services, see [Create gRPC services and methods](https://learn.microsoft.com/aspnet/core/grpc/services).

```csharp
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddGrpc();
}

public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}

app.UseRouting();

app.UseEndpoints(endpoints =>
{
endpoints.MapGrpcService<GreeterService>();
});
}
}
using GrpcGreeter.Services;

var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddGrpc();

var app = builder.Build();

// Configure the HTTP request pipeline.
app.MapGrpcService<GreeterService>();

app.Run();
```

ASP.NET Core middleware and features share the routing pipeline, therefore an app can be configured to serve additional request handlers. The additional request handlers, such as MVC controllers, work in parallel with the configured gRPC services.

## Links

* [Documentation](https://docs.microsoft.com/aspnet/core/grpc/aspnetcore)
* [Documentation](https://learn.microsoft.com/aspnet/core/grpc/aspnetcore)
* [grpc-dotnet GitHub](https://github.com/grpc/grpc-dotnet)