Skip to content

gRPC

func (s *UsersService) GRPC(r *grpc.Registrar) {
r.Register(&pb.Users_ServiceDesc, s,
grpc.Use(dygo.Guards(dygo.Ref[*TokenGuard]())),
grpc.Method("DeleteUser", roles.Set([]string{"admin"})))
}
app.ConnectMicroservice(grpc.NewServer(grpc.Options{Addr: ":50051"}))

The RPC host’s Message() is a *grpc.Call with the method and incoming metadata. Errors map to real codes: errs.NotFound becomes codes.NotFound, BadRequest InvalidArgument, Unauthorized Unauthenticated, panics Internal. grpc.ToHTTPError(err) maps a client error back.