Commit 7cc09863 by dingsongjie

添加 grpc web

parent 0405a997
...@@ -6,9 +6,13 @@ ...@@ -6,9 +6,13 @@
<ItemGroup> <ItemGroup>
<Compile Remove="Application\**" /> <Compile Remove="Application\**" />
<Compile Remove="Logger\**" />
<Content Remove="Application\**" /> <Content Remove="Application\**" />
<Content Remove="Logger\**" />
<EmbeddedResource Remove="Application\**" /> <EmbeddedResource Remove="Application\**" />
<EmbeddedResource Remove="Logger\**" />
<None Remove="Application\**" /> <None Remove="Application\**" />
<None Remove="Logger\**" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
......
...@@ -16,12 +16,13 @@ namespace Backet.Api.GrpcServices ...@@ -16,12 +16,13 @@ namespace Backet.Api.GrpcServices
{ {
this.clusterClient = clusterClient; this.clusterClient = clusterClient;
} }
public override Task<Pole.Grpc.ExtraType.CommonCommandResponse> AddBacket(AddBacketRequest backetDto, ServerCallContext context) public override async Task<Pole.Grpc.ExtraType.CommonCommandResponse> AddBacket(AddBacketRequest backetDto, ServerCallContext context)
{ {
var newId = Guid.NewGuid().ToString("N").ToLower(); var newId = Guid.NewGuid().ToString("N").ToLower();
backetDto.Id = newId; backetDto.Id = newId;
var grain = clusterClient.GetGrain<IAddBacketGrain>(newId); var grain = clusterClient.GetGrain<IAddBacketGrain>(newId);
return Task.FromResult(Pole.Grpc.ExtraType.CommonCommandResponse.SuccessResponse); //await grain.AddBacket(backetDto);
return Pole.Grpc.ExtraType.CommonCommandResponse.SuccessResponse;
} }
} }
} }
...@@ -31,6 +31,7 @@ namespace Backet.Api ...@@ -31,6 +31,7 @@ namespace Backet.Api
services.AddGrpc(); services.AddGrpc();
services.AddGrpcValidation(); services.AddGrpcValidation();
services.AddGrpcRequestValidator(); services.AddGrpcRequestValidator();
services.AddGrpcWeb(o => o.GrpcWebEnabled = true);
services.AddPole(config => services.AddPole(config =>
{ {
...@@ -64,6 +65,8 @@ namespace Backet.Api ...@@ -64,6 +65,8 @@ namespace Backet.Api
app.UsePole(); app.UsePole();
app.UseRouting(); app.UseRouting();
app.UseGrpcWeb();
app.UseEndpoints(endpoints => app.UseEndpoints(endpoints =>
{ {
endpoints.MapDefaultControllerRoute(); endpoints.MapDefaultControllerRoute();
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="FluentValidation" Version="8.6.0" /> <PackageReference Include="FluentValidation" Version="8.6.0" />
<PackageReference Include="Grpc.AspNetCore" Version="2.26.0" /> <PackageReference Include="Grpc.AspNetCore" Version="2.26.0" />
<PackageReference Include="Grpc.AspNetCore.Web" Version="2.27.0-pre1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment