From b0e3966007dcecc53fa6bdccc3e4a4f7652a9176 Mon Sep 17 00:00:00 2001 From: Elivo Date: Sun, 20 Jul 2025 02:44:18 +0800 Subject: [PATCH] =?UTF-8?q?Mini=20=E5=A2=9E=E5=8A=A0=20IPEndPoint=20?= =?UTF-8?q?=E5=8F=82=E6=95=B0=E9=87=8D=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Apewer.Web/Web/ApiProgram.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/Apewer.Web/Web/ApiProgram.cs b/Apewer.Web/Web/ApiProgram.cs index 64b0e4b..88238d9 100644 --- a/Apewer.Web/Web/ApiProgram.cs +++ b/Apewer.Web/Web/ApiProgram.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Net; using System.Text; #if NETFX @@ -62,15 +63,20 @@ namespace Apewer.Web static MiniServer _mini = null; /// 启动 Mini 服务器,返回错误消息。 - public static string Mini(int port = 80, bool await = true) + public static string Mini(IPEndPoint endpoint, bool await = true) { + if (endpoint == null) throw new ArgumentNullException(nameof(endpoint)); + if (_mini != null) return "无法重复启动实例。"; _mini = new MiniServer(); _mini.Handler = context => _invoker.Invoke(new MiniProvider(context)); - _mini.Run(port, await); + _mini.Run(endpoint, await); return null; } + /// 启动 Mini 服务器,返回错误消息。 + public static string Mini(int port = 80, bool await = true) => Mini(new IPEndPoint(IPAddress.Any, port)); + } #if NETCORE @@ -124,7 +130,7 @@ namespace Apewer.Web public partial class ApiProgram : IHttpHandler, IHttpModule { - #region IHttpHandler + #region IHttpHandler static bool _initialized = false; @@ -142,9 +148,9 @@ namespace Apewer.Web _invoker.Invoke(new WebsiteProvider(context)); } - #endregion + #endregion - #region IHttpModule + #region IHttpModule /// public void Dispose() { } @@ -171,7 +177,7 @@ namespace Apewer.Web { } - #endregion + #endregion }