Xunet.MiniApi
1.0.20
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Xunet.MiniApi --version 1.0.20
NuGet\Install-Package Xunet.MiniApi -Version 1.0.20
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="Xunet.MiniApi" Version="1.0.20" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Xunet.MiniApi" Version="1.0.20" />
<PackageReference Include="Xunet.MiniApi" />
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 Xunet.MiniApi --version 1.0.20
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Xunet.MiniApi, 1.0.20"
#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 Xunet.MiniApi@1.0.20
#: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=Xunet.MiniApi&version=1.0.20
#tool nuget:?package=Xunet.MiniApi&version=1.0.20
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Xunet.MiniApi
面向微服务的.NET 最小API支持,功能特性包括:
- 自定义请求处理中间件,统一的数据格式返回
- 自定义异常处理中间件,全局异常处理
- 自定义参数签名中间件,支持参数签名
- 基于System.Text.Json的序列化和反序列化
- 基于OpenIddict实现客户端向认证中心注册
- 内置健康检查、Swagger接口说明文档
- 内置SqlSugar ORM框架,支持Sqlite、MySql、SqlServer快捷使用
- 内置FluentValidation框架,实现请求参数验证器
- 内置Redis缓存、MemoryCache缓存
- 支持Jwt认证、自定义授权策略、跨域策略
- 支持限流、事件、授权、映射器等扩展功能
- 支持阿里云对象存储、阿里云短信服务
- 支持腾讯云对象存储、腾讯云短信服务
- 支持微信公众号开发,内置微信公众号相关接口
Support .NET 8.0+
安装
Xunet.MiniApi 以 NuGet 包的形式提供。您可以使用 NuGet 包控制台窗口安装它:
PM> Install-Package Xunet.MiniApi
使用
Program.cs
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddXunetCache();
builder.Services.AddXunetJsonOptions();
builder.Services.AddXunetFluentValidation();
builder.Services.AddXunetHttpContextAccessor();
builder.Services.AddXunetHealthChecks();
builder.Services.AddXunetSwagger();
builder.Services.AddXunetSqliteStorage();
builder.Services.AddXunetJwtBearer();
builder.Services.AddXunetCors();
builder.Services.AddXunetRateLimiter();
builder.Services.AddXunetEventHandler();
builder.Services.AddXunetAuthorizationHandler();
builder.Services.AddXunetMapper();
var app = builder.Build();
// Configure the HTTP request pipeline.
app.UseXunetCustomException();
app.UseXunetRequestHandler();
app.UseXunetHttpContextAccessor();
app.UseXunetHealthChecks();
app.UseXunetSwagger();
app.UseXunetStorage();
app.UseXunetCors();
app.UseRateLimiter();
app.UseAuthentication();
app.UseAuthorization();
// Configure the MiniApi request pipeline.
app.Run();
PermissionHandler.cs
public class PermissionHandler : AuthorizationHandler<PermissionRequirement>
{
protected override async Task HandleRequirementAsync(AuthorizationHandlerContext context, PermissionRequirement requirement)
{
if (context.User.Identity != null && context.User.Identity.IsAuthenticated)
{
// 已认证,鉴权
await Task.CompletedTask;
context.Succeed(requirement);
}
else
{
context.Fail();
}
}
}
appsettings.Development.json
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"Kestrel": {
"EndPoints": {
"Http": {
"Url": "http://0.0.0.0:8000"
},
"Http2": {
"Url": "http://0.0.0.0:8080",
"Protocols": "Http2"
}
}
},
"CorsHosts": [],
"ConnectionStrings": {
"DefaultConnection": "server=127.0.0.1;uid=root;pwd=root;database=miniapi;max pool size=8000;Charset=utf8;SslMode=none;Allow User Variables=True;",
"RedisConnection": "127.0.0.1:6379"
},
"JwtConfig": {
"ValidateIssuer": true,
"ValidIssuer": "miniapi",
"ValidateIssuerSigningKey": true,
"SymmetricSecurityKey": "294c66d31f8c4ec0b243bb7479cc38e0",
"ValidateAudience": true,
"ValidAudience": "manager",
"ValidateLifetime": true,
"RequireExpirationTime": true,
"ClockSkew": 1,
"RefreshTokenAudience": "manager",
"Expire": 2592000,
"RefreshTokenExpire": 10080
},
"SwaggerOptions": {
"DocumentTitle": "测试接口服务",
"Endpoints": [
{
"EndpointName": "测试接口",
"Title": "测试标题",
"Description": "测试描述",
"Name": "test"
}
]
}
}
更新日志
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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.
-
net8.0
- AlibabaCloud.SDK.Dysmsapi20170525 (>= 4.0.0)
- Aliyun.OSS.SDK.NetCore (>= 2.14.1)
- AutoMapper (>= 14.0.0)
- Caching.CSRedis (>= 3.8.800)
- FluentScheduler (>= 5.5.1)
- FluentValidation (>= 12.0.0)
- FluentValidation.DependencyInjectionExtensions (>= 12.0.0)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 8.0.8)
- Microsoft.AspNetCore.Http.Features (>= 5.0.17)
- Microsoft.AspNetCore.Mvc.Core (>= 2.3.0)
- Microsoft.AspNetCore.OpenApi (>= 8.0.8)
- OpenIddict.AspNetCore (>= 6.4.0)
- SkiaSharp (>= 3.119.0)
- SkiaSharp.NativeAssets.Linux.NoDependencies (>= 3.119.0)
- SqlSugarCore (>= 5.1.4.196)
- Swashbuckle.AspNetCore (>= 9.0.1)
- Tencent.QCloud.Cos.Sdk (>= 5.4.48)
- TencentCloudSDK (>= 3.0.1267)
-
net9.0
- AlibabaCloud.SDK.Dysmsapi20170525 (>= 4.0.0)
- Aliyun.OSS.SDK.NetCore (>= 2.14.1)
- AutoMapper (>= 14.0.0)
- Caching.CSRedis (>= 3.8.800)
- FluentScheduler (>= 5.5.1)
- FluentValidation (>= 12.0.0)
- FluentValidation.DependencyInjectionExtensions (>= 12.0.0)
- Microsoft.AspNetCore.Authentication.JwtBearer (>= 9.0.6)
- Microsoft.AspNetCore.Http.Features (>= 5.0.17)
- Microsoft.AspNetCore.Mvc.Core (>= 2.3.0)
- Microsoft.AspNetCore.OpenApi (>= 9.0.6)
- OpenIddict.AspNetCore (>= 6.4.0)
- SkiaSharp (>= 3.119.0)
- SkiaSharp.NativeAssets.Linux.NoDependencies (>= 3.119.0)
- SqlSugarCore (>= 5.1.4.196)
- Swashbuckle.AspNetCore (>= 9.0.1)
- Tencent.QCloud.Cos.Sdk (>= 5.4.48)
- TencentCloudSDK (>= 3.0.1267)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.0.36 | 84 | 7/31/2025 |
1.0.35 | 105 | 7/28/2025 |
1.0.34 | 86 | 7/28/2025 |
1.0.33 | 89 | 7/27/2025 |
1.0.32 | 306 | 7/25/2025 |
1.0.31 | 311 | 7/25/2025 |
1.0.30 | 439 | 7/24/2025 |
1.0.29 | 183 | 7/20/2025 |
1.0.28 | 183 | 7/19/2025 |
1.0.27 | 143 | 7/14/2025 |
1.0.26 | 136 | 7/13/2025 |
1.0.25 | 95 | 7/12/2025 |
1.0.24 | 79 | 7/11/2025 |
1.0.23 | 128 | 7/11/2025 |
1.0.22 | 128 | 7/10/2025 |
1.0.21 | 121 | 7/10/2025 |
1.0.20 | 68 | 7/5/2025 |
1.0.19 | 67 | 7/5/2025 |
1.0.18 | 168 | 6/26/2025 |