feat: 二维码访问功能,统一端点管道增强,端点迁移至 Services 层
- 新增二维码生成端点,自动检测局域网 IP,前端扫一扫即可打开网站 - 提取 IApiResponse 接口,ServiceRequestBinder 支持强类型请求 DTO 绑定 - FileStream 端点迁移至 AppEndpoints 统一注册,管道支持 FileStreamResponse 原始文件返回 - 文件库端点全面使用 MapGet<TService, TRequest> 泛型注册 - 移除 Avalonia-API/Extensions 中的业务端点文件,统一由 Services 层管理
This commit is contained in:
@@ -109,10 +109,19 @@ namespace Avalonia_Services.Extensions
|
||||
Dictionary<string, string>? query = null)
|
||||
{
|
||||
// 查找匹配的端点(忽略大小写 + 方法匹配)
|
||||
var endpoint = _endpoints.Endpoints.FirstOrDefault(e =>
|
||||
e.SupportsHost(EndpointHostTarget.Pc) &&
|
||||
string.Equals(e.Pattern, path, StringComparison.OrdinalIgnoreCase) &&
|
||||
string.Equals(e.HttpMethod, method, StringComparison.OrdinalIgnoreCase));
|
||||
var match = _endpoints.Endpoints
|
||||
.Where(e =>
|
||||
e.SupportsHost(EndpointHostTarget.Pc) &&
|
||||
string.Equals(e.HttpMethod, method, StringComparison.OrdinalIgnoreCase))
|
||||
.Select(e => new
|
||||
{
|
||||
Endpoint = e,
|
||||
IsMatched = ServiceEndpointPatternMatcher.TryMatch(e.Pattern, path, out var routeValues),
|
||||
RouteValues = routeValues,
|
||||
})
|
||||
.FirstOrDefault(candidate => candidate.IsMatched);
|
||||
|
||||
var endpoint = match?.Endpoint;
|
||||
|
||||
if (endpoint is null)
|
||||
{
|
||||
@@ -127,6 +136,7 @@ namespace Avalonia_Services.Extensions
|
||||
Body = body,
|
||||
Headers = headers ?? new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase),
|
||||
Query = query ?? new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase),
|
||||
RouteValues = match!.RouteValues,
|
||||
Items = { ["ServiceProvider"] = _serviceProvider },
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user