Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
polysoft-nafmii
/
polysoft-parent
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit c7cae427
authored
Apr 29, 2021
by
ypenglv
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
gateway聚合swagger,修改配置
1 parent
01f29afb
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
1 deletions
nafmii-gateway/src/main/java/org/nafmii/gateway/config/MySwaggerResourceProvider.java
nafmii-gateway/src/main/java/org/nafmii/gateway/config/SwaggerResourceController.java
nafmii-gateway/src/main/resources/application-dev.yml
nafmii-gateway/src/main/java/org/nafmii/gateway/config/MySwaggerResourceProvider.java
View file @
c7cae42
...
...
@@ -29,6 +29,9 @@ public class MySwaggerResourceProvider implements SwaggerResourcesProvider {
* 网关路由
*/
private
final
RouteLocator
routeLocator
;
private
final
String
serverName1
=
"NAFMII-APP"
;
private
final
String
serverName2
=
"GATEWAY"
;
private
final
String
serverName3
=
"NAFMII-ADMIN"
;
/**
* 网关应用名称
...
...
@@ -47,7 +50,9 @@ public class MySwaggerResourceProvider implements SwaggerResourcesProvider {
// 由于我的网关采用的是负载均衡的方式,因此我需要拿到所有应用的serviceId
// 获取所有可用的host:serviceId
routeLocator
.
getRoutes
().
filter
(
route
->
route
.
getUri
().
getHost
()
!=
null
)
.
filter
(
route
->
!
self
.
equals
(
route
.
getUri
().
getHost
()))
.
filter
(
route
->
!
serverName1
.
equals
(
route
.
getUri
().
getHost
()))
.
filter
(
route
->
!
serverName2
.
equals
(
route
.
getUri
().
getHost
()))
.
filter
(
route
->
!
serverName3
.
equals
(
route
.
getUri
().
getHost
()))
.
subscribe
(
route
->
routeHosts
.
add
(
route
.
getUri
().
getHost
()));
// 记录已经添加过的server,存在同一个应用注册了多个服务在nacos上
...
...
nafmii-gateway/src/main/java/org/nafmii/gateway/config/SwaggerResourceController.java
View file @
c7cae42
...
...
@@ -10,6 +10,8 @@ import reactor.core.publisher.Mono;
import
springfox.documentation.swagger.web.*
;
import
javax.annotation.Resource
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Optional
;
/**
...
...
nafmii-gateway/src/main/resources/application-dev.yml
View file @
c7cae42
...
...
@@ -9,6 +9,7 @@ eureka:
instance
:
prefer-ip-address
:
true
instance-id
:
${spring.cloud.client.ip-address}:${server.port}
statusPageUrl
:
http://127.0.0.1:9000/swagger-ui.html
spring
:
application
:
name
:
gateway
...
...
Write
Preview
Markdown
is supported
Attach a file
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 post a comment