# grpcFormat **Repository Path**: yuanlong_project/grpc-format ## Basic Information - **Project Name**: grpcFormat - **Description**: 一款grpc的格式化插件,使用此插件可使 WebApi 根据客户端的字段要求返回相应格式的数据,降低数据传输量。 - **Primary Language**: C# - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-01-31 - **Last Updated**: 2024-01-07 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # grpcFormat #### 介绍 一款grpc的格式化插件,可通过客户端的指定规范返回对应格式的数据,降低数据传输量。 #### 软件架构 无 #### 安装教程 1. Nuget仓库搜索grpcFormat插件。 #### 使用说明 1. 在Startup.cs文件中的ConfigureServices函数中,找到services.AddMvc函数,增加 GrpcFormat.GrpcFormatResultFilter 的注入。 如图所示: ```csharp services.AddMvc(options => { ... options.Filters.Add(); }). ``` 2. 客户端在请求时,在headers中增加Grpc-Format表头,并按照gRPC的格式要求,传入格式的要求。 示例代码: ```csharp var client = new RestClient("https://localhost:44337/weatherforecast"); client.Timeout = -1; var request = new RestRequest(Method.GET); request.AddHeader("Grpc-Format", "{id,name}"); IRestResponse response = client.Execute(request); Console.WriteLine(response.Content); ``` #### 参与贡献 1. Fork 本仓库 2. 新建 Feat_xxx 分支 3. 提交代码 4. 新建 Pull Request #### 特技