Compare commits

...
2 Commits
Author SHA1 Message Date
xrain 506704fd90 fix fullurl 不抛出异常了 2024-07-10 06:29:36 +08:00
xrain 786051ddbf update pkg 2024-07-10 03:30:09 +08:00
3 changed files with 9 additions and 10 deletions
+5 -3
View File
@@ -3,15 +3,16 @@ using System;
using System.IO; using System.IO;
using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Http;
using Minio; using Minio;
using Minio.DataModel.Args;
using SimApi.Configurations; using SimApi.Configurations;
namespace SimApi.Helpers; namespace SimApi.Helpers;
public class SimApiStorage public class SimApiStorage
{ {
private MinioClient Mc { get; } private IMinioClient Mc { get; }
public MinioClient Client => Mc; public IMinioClient Client => Mc;
private string ServeUrl { get; } private string ServeUrl { get; }
@@ -113,8 +114,9 @@ public class SimApiStorage
/// <exception cref="Exception"></exception> /// <exception cref="Exception"></exception>
public string FullUrl(string path) public string FullUrl(string path)
{ {
if (string.IsNullOrEmpty(path)) return path;
if(path.StartsWith("http://") || path.StartsWith("https://")) return path; if(path.StartsWith("http://") || path.StartsWith("https://")) return path;
if (!(path.StartsWith('/') || path.StartsWith("~/"))) throw new Exception("path must start with / or ~/"); if (!(path.StartsWith('/') || path.StartsWith("~/"))) return path;
var httpRequest = HttpContextAccessor.HttpContext?.Request; var httpRequest = HttpContextAccessor.HttpContext?.Request;
var url = $"{httpRequest?.Scheme}://{httpRequest?.Host}"; var url = $"{httpRequest?.Scheme}://{httpRequest?.Host}";
if (string.IsNullOrEmpty(path)) if (string.IsNullOrEmpty(path))
+4 -4
View File
@@ -25,10 +25,10 @@
<Folder Include="Exceptions\"/> <Folder Include="Exceptions\"/>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Minio" Version="4.0.7"/> <PackageReference Include="Minio" Version="6.0.3" />
<PackageReference Include="RabbitMQ.Client" Version="6.6.0"/> <PackageReference Include="RabbitMQ.Client" Version="6.8.1" />
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.5.0"/> <PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="6.6.2" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.5.0"/> <PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.6.2" />
</ItemGroup> </ItemGroup>
<ProjectExtensions> <ProjectExtensions>
<MonoDevelop> <MonoDevelop>
-3
View File
@@ -1,11 +1,8 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using System.Text.Encodings.Web;
using System.Text.Json; using System.Text.Json;
using System.Text.Unicode;
using Microsoft.Extensions.Logging; using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Serialization;
using RabbitMQ.Client.Events; using RabbitMQ.Client.Events;
using SimApi.Communications; using SimApi.Communications;
using SimApi.Helpers; using SimApi.Helpers;