-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgrpc-integrace-grpc-server-macos.cs
More file actions
executable file
·46 lines (38 loc) · 1.35 KB
/
grpc-integrace-grpc-server-macos.cs
File metadata and controls
executable file
·46 lines (38 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Server.csproj
<PackageReference Include="Grpc.AspNetCore" Version="2.33.1" />
<ItemGroup>
<Protobuf Include="Protos\greet.proto" GrpcServices="Server" Link="Protos\greet.proto" />
</ItemGroup>
<ItemGroup>
<Content Update="Protos\*">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>
</ItemGroup>
// WebApplicationBuilder (builder.Services)
// podpora pro macOS
WebHost.ConfigureKestrel(options =>
{
options.ListenLocalhost(5000, o => o.Protocols = HttpProtocols.Http2); // gRPC
options.ListenLocalhost(5003, o => o.Protocols = HttpProtocols.Http1); // protos
});
// WebApplication
app.UseStaticFiles(new StaticFileOptions
{
FileProvider = new PhysicalFileProvider(Path.Combine(env.ContentRootPath, "Protos")),
RequestPath = "/Protos",
ContentTypeProvider = provider
});
app.UseDirectoryBrowser(new DirectoryBrowserOptions
{
FileProvider = new PhysicalFileProvider(Path.Combine(env.ContentRootPath, "Protos")),
RequestPath = "/Protos"
});
app.MapGrpcService<GreeterService>();
app.MapGet("/", async context =>
{
context.Response.Redirect("/Protos");
});
app.Map("/{p1?}/{p2?}/{p3?}", 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");
});