Ybd.AbpLite.UnifiedResponse
2.0.0
dotnet add package Ybd.AbpLite.UnifiedResponse --version 2.0.0
NuGet\Install-Package Ybd.AbpLite.UnifiedResponse -Version 2.0.0
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Ybd.AbpLite.UnifiedResponse" Version="2.0.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Ybd.AbpLite.UnifiedResponse" Version="2.0.0" />
<PackageReference Include="Ybd.AbpLite.UnifiedResponse" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Ybd.AbpLite.UnifiedResponse --version 2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Ybd.AbpLite.UnifiedResponse, 2.0.0"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Ybd.AbpLite.UnifiedResponse@2.0.0
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Ybd.AbpLite.UnifiedResponse&version=2.0.0
#tool nuget:?package=Ybd.AbpLite.UnifiedResponse&version=2.0.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Ybd.AbpLite.UnifiedResponse
ABP 统一返回模块。默认把 /api/app 下的成功结果、业务异常、参数校验、401/403 包装成:
{ "success": true, "data": { }, "error": null }
{
"success": false,
"data": null,
"error": {
"code": "MyProject:Order:0001",
"message": "订单不存在",
"details": null,
"data": null,
"validationErrors": []
}
}
错误信息直接使用 ABP 的 RemoteServiceErrorInfo,因此保留 ABP 的错误码、本地化和校验结构。
引入
[DependsOn(typeof(AbpLiteUnifiedResponseModule))]
public class MyHostModule : AbpModule
{
}
配置节 UnifiedResponse:
{
"UnifiedResponse": {
"Enabled": true,
"Mode": "Envelope",
"AllowNativeOverride": true,
"IncludePaths": [ "/api/app" ],
"ExcludePaths": [ "/swagger", "/api/abp" ],
"AlwaysReturnHttp200": false,
"ErrorCodePrefix": "MyProject"
}
}
原生格式
前端默认拿信封。ABP 动态客户端共享 Application.Contracts 时,不希望成功响应被包一层,可以:
X-Unified-Response: native
服务端会返回裸 DTO 和 ABP 原生错误。Ybd.AbpLite.UnifiedResponse.Client 包会自动给 ABP 动态代理加这个请求头。
自定义
- 换信封结构:实现
IUnifiedResponseBuilder并替换默认实现; - 换异常/状态码映射:实现
IUnifiedResponseErrorMapper; - 换包装范围:实现
IUnifiedResponsePolicy; - 换响应写入:实现
IUnifiedResponseWriter; - 单个接口退出:标
[SkipUnifiedResponse]。
所有默认实现都通过 ABP 依赖注入注册,使用 [Dependency(ReplaceServices = true)] 即可替换。
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net10.0
- System.IdentityModel.Tokens.Jwt (>= 8.19.2)
- Volo.Abp.AspNetCore (>= 10.7.0)
- Volo.Abp.AspNetCore.Mvc (>= 10.7.0)
- Volo.Abp.ExceptionHandling (>= 10.7.0)
- Volo.Abp.Http (>= 10.7.0)
- Volo.Abp.Localization (>= 10.7.0)
- Volo.Abp.Security (>= 10.7.0)
- Ybd.AbpLite.UnifiedResponse.Abstractions (>= 1.0.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.