feat: added user gRPC service
This commit is contained in:
parent
7f5374d433
commit
bff642e687
15
Contracts/Proto/user.proto
Normal file
15
Contracts/Proto/user.proto
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
syntax = "proto3";
|
||||||
|
option csharp_namespace = "JOBot.Proto";
|
||||||
|
|
||||||
|
service User {
|
||||||
|
rpc Register (RegisterRequest) returns (RegisterResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
message RegisterRequest{
|
||||||
|
int64 user_id = 1;
|
||||||
|
string username = 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
message RegisterResponse{
|
||||||
|
int64 user_id = 1;
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk.Web">
|
<Project Sdk="Microsoft.NET.Sdk.Web">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>net9.0</TargetFramework>
|
<TargetFramework>net9.0</TargetFramework>
|
||||||
@ -15,4 +15,8 @@
|
|||||||
</PackageReference>
|
</PackageReference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Protobuf Include="..\Contracts\Proto\*" GrpcServices="Server"></Protobuf>
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
||||||
|
builder.Services.AddGrpc();
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
app.MapGet("/", () => "Hello World!");
|
app.MapGrpcService<UserService>();
|
||||||
|
|
||||||
app.Run();
|
app.Run();
|
16
JOBot.Backend/Services/gRPC/UserService.cs
Normal file
16
JOBot.Backend/Services/gRPC/UserService.cs
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
using Grpc.Core;
|
||||||
|
using JOBot.Proto;
|
||||||
|
|
||||||
|
class UserService : User.UserBase
|
||||||
|
{
|
||||||
|
public override Task<RegisterResponse> Register(
|
||||||
|
RegisterRequest request,
|
||||||
|
ServerCallContext context)
|
||||||
|
|
||||||
|
{
|
||||||
|
return Task.FromResult(new RegisterResponse
|
||||||
|
{
|
||||||
|
UserId = request.UserId
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user