星尘网关

This commit is contained in:
大石头 2020-10-08 10:26:58 +08:00
parent 802956d695
commit 065cd335af
4 changed files with 118 additions and 0 deletions

49
StarGateway/Program.cs Normal file
View File

@ -0,0 +1,49 @@
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Hosting;
using NewLife.Log;
using Stardust.Data;
namespace StarGateway
{
class Program
{
public static void Main(String[] args)
{
XTrace.UseConsole();
// 异步初始化
Task.Run(InitAsync);
CreateWebHostBuilder(args).Build().Run();
}
public static IHostBuilder CreateWebHostBuilder(String[] args)
{
var builder = Host.CreateDefaultBuilder(args);
//builder.ConfigureWebHostDefaults(webBuilder =>
//{
// var set = Setting.Current;
// if (set.Port > 0) webBuilder.UseUrls($"http://*:{set.Port}");
// webBuilder.UseStartup<Startup>();
//});
return builder;
}
private static void InitAsync()
{
// 配置
var set = NewLife.Setting.Current;
if (set.IsNew)
{
set.DataPath = "../Data";
set.Save();
}
// 初始化数据库
var n = App.Meta.Count;
AppStat.Meta.Session.Dal.Db.ShowSQL = false;
}
}
}

25
StarGateway/Setting.cs Normal file
View File

@ -0,0 +1,25 @@
using System;
using System.ComponentModel;
using NewLife.Configuration;
namespace StarGateway
{
/// <summary>配置</summary>
[Config("StarGateway")]
public class Setting : Config<Setting>
{
#region
/// <summary>调试开关。默认true</summary>
[Description("调试开关。默认true")]
public Boolean Debug { get; set; } = true;
/// <summary>服务端口。默认8800</summary>
[Description("服务端口。默认8800")]
public Int32 Port { get; set; } = 8800;
/// <summary>令牌密钥。用于生成JWT令牌的算法和密钥如HS256:ABCD1234</summary>
[Description("令牌密钥。用于生成JWT令牌的算法和密钥如HS256:ABCD1234")]
public String TokenSecret { get; set; }
#endregion
}
}

View File

@ -0,0 +1,38 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AssemblyTitle>星尘网关</AssemblyTitle>
<Description>星尘网关,转发网络请求,实现路由切换。</Description>
<Company>新生命开发团队</Company>
<Copyright>©2002-2020 NewLife</Copyright>
<Version>1.0.2020.1006</Version>
<FileVersion>1.0.2020.1006</FileVersion>
<AssemblyVersion>1.0.*</AssemblyVersion>
<Deterministic>false</Deterministic>
<OutputPath>..\Bin\Gateway</OutputPath>
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<DefineConstants>TRACE</DefineConstants>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<DefineConstants>$(DefineConstants);DEBUG</DefineConstants>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="3.1.8" />
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="3.1.8" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Stardust.Data\Stardust.Data.csproj" />
<ProjectReference Include="..\Stardust\Stardust.csproj" />
</ItemGroup>
</Project>

View File

@ -33,6 +33,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Stardust.ServerTests", "Sta
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StarAgentTool", "StarAgentTool\StarAgentTool.csproj", "{4DA8CFA1-A2B9-4DD0-86C1-19925BA076B2}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StarGateway", "StarGateway\StarGateway.csproj", "{94CCBB9E-628D-4381-8E2C-DF349EFD204F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@ -75,6 +77,10 @@ Global
{4DA8CFA1-A2B9-4DD0-86C1-19925BA076B2}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4DA8CFA1-A2B9-4DD0-86C1-19925BA076B2}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4DA8CFA1-A2B9-4DD0-86C1-19925BA076B2}.Release|Any CPU.Build.0 = Release|Any CPU
{94CCBB9E-628D-4381-8E2C-DF349EFD204F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{94CCBB9E-628D-4381-8E2C-DF349EFD204F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{94CCBB9E-628D-4381-8E2C-DF349EFD204F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{94CCBB9E-628D-4381-8E2C-DF349EFD204F}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE