Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
O
OTWebSocketHub
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李福茂
OTWebSocketHub
Commits
86b8c97f
Commit
86b8c97f
authored
May 25, 2021
by
Maodashu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修复swagger配置bug
parent
9c082f6c
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
19 deletions
+31
-19
OTWebSocket.API.csproj
OTWebSocket.API/OTWebSocket.API.csproj
+6
-0
launchSettings.json
OTWebSocket.API/Properties/launchSettings.json
+6
-0
Startup.cs
OTWebSocket.API/Startup.cs
+19
-19
No files found.
OTWebSocket.API/OTWebSocket.API.csproj
View file @
86b8c97f
...
...
@@ -29,6 +29,12 @@
<PackageReference Include="System.Net.Http.Json" Version="5.0.0" />
</ItemGroup>
<ItemGroup>
<None Update="OTWebSocket.API.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
</ItemGroup>
<ProjectExtensions><VisualStudio><UserProperties /></VisualStudio></ProjectExtensions>
</Project>
OTWebSocket.API/Properties/launchSettings.json
View file @
86b8c97f
...
...
@@ -7,6 +7,12 @@
"ASPNETCORE_ENVIRONMENT"
:
"Development"
},
"applicationUrl"
:
"http://localhost:5000"
},
"Docker"
:
{
"commandName"
:
"Docker"
,
"launchBrowser"
:
true
,
"launchUrl"
:
"{Scheme}://{ServiceHost}:{ServicePort}"
,
"publishAllPorts"
:
true
}
}
}
\ No newline at end of file
OTWebSocket.API/Startup.cs
View file @
86b8c97f
u
sing
Microsoft.AspNetCore.Builder
;
u
sing
Microsoft.AspNetCore.Builder
;
using
Microsoft.AspNetCore.Hosting
;
using
Microsoft.Extensions.Configuration
;
using
Microsoft.Extensions.DependencyInjection
;
...
...
@@ -47,7 +47,7 @@ namespace OTWebSocket.API
services
.
AddControllers
();
services
.
AddMvcCore
().
AddNewtonsoftJson
();
#
region
业务类服务
#
region
业务类服务
services
.
AddSingleton
<
WebSocketService
>();
...
...
@@ -79,22 +79,22 @@ namespace OTWebSocket.API
c
.
SwaggerDoc
(
"debug"
,
new
OpenApiInfo
{
Version
=
"v1"
,
Description
=
"1-Token WebsocketHub Swagger
接口文档 V1 基于
Asp.net Core 3.1"
,
Title
=
"
调试接口
"
,
Description
=
"1-Token WebsocketHub Swagger
接口文档 V1 基于Asp
.net Core 3.1"
,
Title
=
"
调试接口"
,
});
c
.
SwaggerDoc
(
"system"
,
new
OpenApiInfo
{
Version
=
"v1"
,
Description
=
"1-Token WebsocketHub Swagger
接口文档 V1 基于
Asp.net Core 3.1"
,
Title
=
"
系统管理接口
"
,
Description
=
"1-Token WebsocketHub Swagger
接口文档 V1 基于Asp
.net Core 3.1"
,
Title
=
"
系统管理接口"
,
});
c
.
SwaggerDoc
(
"other"
,
new
OpenApiInfo
{
Version
=
"v1"
,
Description
=
"1-Token WebsocketHub Swagger
接口文档 V1 基于
Asp.net Core 3.1"
,
Title
=
"
其他接口
"
,
Description
=
"1-Token WebsocketHub Swagger
接口文档 V1 基于Asp
.net Core 3.1"
,
Title
=
"
其他接口"
,
});
c
.
IncludeXmlComments
(
Path
.
Combine
(
AppContext
.
BaseDirectory
,
$"OTWebSocket.API.xml"
));
...
...
@@ -113,7 +113,8 @@ namespace OTWebSocket.API
{
_orderTracer
=
orderTracer
;
_logger
=
logger
;
_logger
?.
Debug
(
"=========== 系统服务正在启动 ==========="
);
var
env
=
Environment
.
GetEnvironmentVariable
(
"ASPNETCORE_ENVIRONMENT"
);
_logger
?.
Debug
(
$"=========== 系统服务正在启动 (
{
env
}
) ==========="
);
_webSocketService
=
webSocketService
;
appLifetime
.
ApplicationStarted
.
Register
(
OnStarted
);
...
...
@@ -132,10 +133,9 @@ namespace OTWebSocket.API
var
path
=
Configuration
.
GetSection
(
"Swagger:VirtualPath"
).
Value
;
string
scheme
=
"https"
;
var
env
=
Environment
.
GetEnvironmentVariable
(
"ASPNETCORE_ENVIRONMENT"
);
if
(!
string
.
IsNullOrEmpty
(
env
)
&&
env
.
Equals
(
"Development"
))
{
scheme
=
"http"
;
//
本地测试使用http协议
scheme
=
"http"
;
//
本地测试使用http协议
}
app
.
UseSwagger
(
c
=>
{
...
...
@@ -145,16 +145,16 @@ namespace OTWebSocket.API
});
app
.
UseSwaggerUI
(
c
=>
{
c
.
SwaggerEndpoint
(
$"
{
path
}
/swagger/debug/swagger.json"
,
"
调试接口
"
);
c
.
SwaggerEndpoint
(
$"
{
path
}
/swagger/system/swagger.json"
,
"
服务管理
"
);
c
.
SwaggerEndpoint
(
$"
{
path
}
/swagger/other/swagger.json"
,
"
其他接口
"
);
c
.
SwaggerEndpoint
(
$"
{
path
}
/swagger/debug/swagger.json"
,
"
调试接口"
)
;
c
.
SwaggerEndpoint
(
$"
{
path
}
/swagger/system/swagger.json"
,
"
服务管理"
)
;
c
.
SwaggerEndpoint
(
$"
{
path
}
/swagger/other/swagger.json"
,
"
其他接口"
)
;
});
//MQ
消息消费配置
//MQ
消息消费配置
app
.
UseMatrixOneMQReceiveMethod
(
new
MO
.
RabbitMQ
.
Options
.
RabbitMQReceiveOptions
()
{
Options
=
new
List
<
MO
.
RabbitMQ
.
Options
.
ReceiveOption
>()
{
new
MO
.
RabbitMQ
.
Options
.
ReceiveOption
()
{
//
需要启动查单任务的订单(进行中)消息
new
MO
.
RabbitMQ
.
Options
.
ReceiveOption
()
{
//
需要启动查单任务的订单(进行中)消息
Exchange
=
"onetoken.transient.task"
,
ExchangeType
=
ExchangeTypeEnum
.
Direct
,
RoutingKey
=
"WebSocketHub"
,
...
...
@@ -167,7 +167,7 @@ namespace OTWebSocket.API
private
void
OnStarted
()
{
_logger
.
LogWarning
(
$"[
服务器状态]WebHost 已经启动
(
{
DateTime
.
Now
:
yyyy
-
MM
-
dd
HH
:
mm
:
ss
:
ffff
}
)"
);
_logger
.
LogWarning
(
$"[
服务器状态]WebHost 已经启动(
{
Da
teTime
.
Now
:
yyyy
-
MM
-
dd
HH
:
mm
:
ss
:
ffff
}
)"
);
_orderTracer
.
LiveOrdersCheck
();
_orderTracer
.
StartPoll
();
_webSocketService
.
Start
();
...
...
@@ -175,14 +175,14 @@ namespace OTWebSocket.API
private
void
OnStopping
()
{
_logger
.
LogWarning
(
$"[
服务器状态]WebHost 开始停止
(
{
DateTime
.
Now
:
yyyy
-
MM
-
dd
HH
:
mm
:
ss
:
ffff
}
)"
);
_logger
.
LogWarning
(
$"[
服务器状态]WebHost 开始停止(
{
D
ateTime
.
Now
:
yyyy
-
MM
-
dd
HH
:
mm
:
ss
:
ffff
}
)"
);
_webSocketService
.
Stop
();
_orderTracer
.
StopPoll
();
}
private
void
OnStopped
()
{
_logger
.
LogWarning
(
$"[
服务器状态]WebHost 已经关闭
(
{
DateTime
.
Now
:
yyyy
-
MM
-
dd
HH
:
mm
:
ss
:
ffff
}
)"
);
_logger
.
LogWarning
(
$"[
服务器状态]WebHost 已经关闭(
{
Da
teTime
.
Now
:
yyyy
-
MM
-
dd
HH
:
mm
:
ss
:
ffff
}
)"
);
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment