diff --git a/Dipper.Alioth/Dipper.Alioth.csproj b/Dipper.Alioth/Dipper.Alioth.csproj
index 7a47edc..ff57dfd 100644
--- a/Dipper.Alioth/Dipper.Alioth.csproj
+++ b/Dipper.Alioth/Dipper.Alioth.csproj
@@ -8,6 +8,7 @@
+
diff --git a/Dipper.Alioth/Extensions/StartHostExtension.cs b/Dipper.Alioth/Extensions/StartHostExtension.cs
index 9955c67..796ef3c 100644
--- a/Dipper.Alioth/Extensions/StartHostExtension.cs
+++ b/Dipper.Alioth/Extensions/StartHostExtension.cs
@@ -9,7 +9,7 @@ public static class StartHostExtension
///
///
///
- public static StarHost AddWatchServiceFolder(this StarHost host, string path)
+ public static WebStarHost AddWatchServiceFolder(this WebStarHost host, string path)
{
if (!Directory.Exists(path))
{
diff --git a/Dipper.Alioth/Modules/IModule.cs b/Dipper.Alioth/Modules/IStarModule.cs
similarity index 62%
rename from Dipper.Alioth/Modules/IModule.cs
rename to Dipper.Alioth/Modules/IStarModule.cs
index 45e099b..c482258 100644
--- a/Dipper.Alioth/Modules/IModule.cs
+++ b/Dipper.Alioth/Modules/IStarModule.cs
@@ -1,6 +1,6 @@
namespace Dipper.Alioth;
-public interface IModule
+public interface IStarModule
{
void Initialize();
}
\ No newline at end of file
diff --git a/Dipper.Alioth/Options/StarOption.cs b/Dipper.Alioth/Options/StarOption.cs
index 86a2a99..cfcb46a 100644
--- a/Dipper.Alioth/Options/StarOption.cs
+++ b/Dipper.Alioth/Options/StarOption.cs
@@ -4,12 +4,12 @@ namespace Dipper.Alioth.Options;
public class StarOption
{
- public IList Modules { get; }
- public Action MvcOption { get; set; }
- public Action JsonOption { get; set; }
+ public IList Modules { get; }
+ public Action? MvcOption { get; set; }
+ public Action? JsonOption { get; set; }
public StarOption()
{
- Modules = new List();
+ Modules = new List();
}
}
\ No newline at end of file
diff --git a/Dipper.Alioth/StarHost.cs b/Dipper.Alioth/StarHost.cs
new file mode 100644
index 0000000..aeb9976
--- /dev/null
+++ b/Dipper.Alioth/StarHost.cs
@@ -0,0 +1,12 @@
+using Dipper.Alioth.Options;
+
+namespace Dipper.Alioth;
+
+public abstract class StarHost
+{
+ public abstract void Run(string[] args, Action action);
+
+ public abstract Task RunAsync(string[] args, Action action);
+
+
+}
\ No newline at end of file
diff --git a/Dipper.Alioth/Web/ServiceExtension.cs b/Dipper.Alioth/Web/ServiceExtension.cs
index 95457b3..d153729 100644
--- a/Dipper.Alioth/Web/ServiceExtension.cs
+++ b/Dipper.Alioth/Web/ServiceExtension.cs
@@ -17,7 +17,7 @@ internal static class ServiceExtension
action?.Invoke(option);
- builder.Services.AddControllers(options =>
+ var mvcBuilder = builder.Services.AddControllers(options =>
{
options.EnableEndpointRouting = false;
option.MvcOption?.Invoke(options);
@@ -27,6 +27,12 @@ internal static class ServiceExtension
options.JsonSerializerOptions.PropertyNamingPolicy = null;
option.JsonOption?.Invoke(options);
});
+
+ builder.Services.AddSwaggerGen(options =>
+ {
+
+ });
+ AddFlexibleApi(mvcBuilder, option);
builder.Services.AddSession();
@@ -38,22 +44,30 @@ internal static class ServiceExtension
if (app.Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage();
+ app.UseSwagger();
+ app.UseSwaggerUI();
}
else
{
app.UseExceptionHandler("/?m=Error500");
}
-
+
app.UseStaticFiles();
app.UseHttpsRedirection();
app.UseRouting();
app.UseSession();
app.UseAuthorization();
+ app.MapRazorPages();
app.MapControllers();
return app;
}
+ ///
+ /// 添加动态接口
+ ///
+ ///
+ ///
private static void AddFlexibleApi(IMvcBuilder builder, StarOption option)
{
builder.ConfigureApplicationPartManager(manager =>
diff --git a/Dipper.Alioth/Web/StarHost.cs b/Dipper.Alioth/Web/WebStarHost.cs
similarity index 61%
rename from Dipper.Alioth/Web/StarHost.cs
rename to Dipper.Alioth/Web/WebStarHost.cs
index 2a4b78e..d5ce0eb 100644
--- a/Dipper.Alioth/Web/StarHost.cs
+++ b/Dipper.Alioth/Web/WebStarHost.cs
@@ -4,25 +4,25 @@ using Microsoft.Extensions.DependencyInjection;
namespace Dipper.Alioth.Web;
-public class StarHost
+public class WebStarHost : StarHost
{
- private StarHost()
+ private WebStarHost()
{
}
- public StarHost CreateHost()
+ public static WebStarHost CreateWebHost()
{
- return new StarHost();
+ return new WebStarHost();
}
- public void Run(string[] args, Action action)
+ public override void Run(string[] args, Action action)
{
var app = Configure(args, action);
app.Run();
}
- public Task RunAsync(string[] args, Action action)
+ public override Task RunAsync(string[] args, Action action)
{
var app = Configure(args, action);
@@ -33,8 +33,10 @@ public class StarHost
private WebApplication Configure(string[] args, Action action)
{
var builder = WebApplication.CreateBuilder(args);
-
+ builder.AddStarApp(action);
var app = builder.Build();
+
+ app.UserStarApp();
return app;
}
diff --git a/Dipper.Demo/Dipper.Demo.csproj b/Dipper.Demo/Dipper.Demo.csproj
new file mode 100644
index 0000000..466f901
--- /dev/null
+++ b/Dipper.Demo/Dipper.Demo.csproj
@@ -0,0 +1,13 @@
+
+
+
+ net6.0
+ enable
+ enable
+
+
+
+
+
+
+
diff --git a/Dipper.Demo/Program.cs b/Dipper.Demo/Program.cs
new file mode 100644
index 0000000..9f47f12
--- /dev/null
+++ b/Dipper.Demo/Program.cs
@@ -0,0 +1,8 @@
+using Dipper.Alioth;
+using Dipper.Alioth.Web;
+
+WebStarHost.CreateWebHost()
+ .Run(args, options =>
+ {
+
+ });
\ No newline at end of file
diff --git a/Dipper.Demo/Properties/launchSettings.json b/Dipper.Demo/Properties/launchSettings.json
new file mode 100644
index 0000000..222a26e
--- /dev/null
+++ b/Dipper.Demo/Properties/launchSettings.json
@@ -0,0 +1,28 @@
+{
+ "iisSettings": {
+ "windowsAuthentication": false,
+ "anonymousAuthentication": true,
+ "iisExpress": {
+ "applicationUrl": "http://localhost:42985",
+ "sslPort": 44395
+ }
+ },
+ "profiles": {
+ "Dipper.Demo": {
+ "commandName": "Project",
+ "dotnetRunMessages": true,
+ "launchBrowser": true,
+ "applicationUrl": "https://localhost:7064;http://localhost:5038",
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ },
+ "IIS Express": {
+ "commandName": "IISExpress",
+ "launchBrowser": true,
+ "environmentVariables": {
+ "ASPNETCORE_ENVIRONMENT": "Development"
+ }
+ }
+ }
+}
diff --git a/Dipper.Demo/appsettings.Development.json b/Dipper.Demo/appsettings.Development.json
new file mode 100644
index 0000000..0c208ae
--- /dev/null
+++ b/Dipper.Demo/appsettings.Development.json
@@ -0,0 +1,8 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ }
+}
diff --git a/Dipper.Demo/appsettings.json b/Dipper.Demo/appsettings.json
new file mode 100644
index 0000000..10f68b8
--- /dev/null
+++ b/Dipper.Demo/appsettings.json
@@ -0,0 +1,9 @@
+{
+ "Logging": {
+ "LogLevel": {
+ "Default": "Information",
+ "Microsoft.AspNetCore": "Warning"
+ }
+ },
+ "AllowedHosts": "*"
+}
diff --git a/Dipper.sln b/Dipper.sln
index 3683bcb..21dbea2 100644
--- a/Dipper.sln
+++ b/Dipper.sln
@@ -2,6 +2,8 @@
Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dipper.Alioth", "Dipper.Alioth\Dipper.Alioth.csproj", "{EF5E7BBF-F064-49A9-A191-EE67DA70CC8E}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Dipper.Demo", "Dipper.Demo\Dipper.Demo.csproj", "{F075C721-EA36-4B54-B90B-0CC4AA1D641C}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -12,5 +14,9 @@ Global
{EF5E7BBF-F064-49A9-A191-EE67DA70CC8E}.Debug|Any CPU.Build.0 = Debug|Any CPU
{EF5E7BBF-F064-49A9-A191-EE67DA70CC8E}.Release|Any CPU.ActiveCfg = Release|Any CPU
{EF5E7BBF-F064-49A9-A191-EE67DA70CC8E}.Release|Any CPU.Build.0 = Release|Any CPU
+ {F075C721-EA36-4B54-B90B-0CC4AA1D641C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {F075C721-EA36-4B54-B90B-0CC4AA1D641C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {F075C721-EA36-4B54-B90B-0CC4AA1D641C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {F075C721-EA36-4B54-B90B-0CC4AA1D641C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
EndGlobal