Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
sl-gateway
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
zhouwei
sl-gateway
Commits
18300239
Commit
18300239
authored
Apr 14, 2025
by
zhouwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
请求转发携带model和model key
parent
633730f7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
1 deletion
+9
-1
FailoverProperties.java
...va/com/nanyan/securitylink/config/FailoverProperties.java
+2
-0
FailoverGatewayFilterFactory.java
...yan/securitylink/filter/FailoverGatewayFilterFactory.java
+7
-1
No files found.
src/main/java/com/nanyan/securitylink/config/FailoverProperties.java
View file @
18300239
...
...
@@ -25,5 +25,7 @@ public class FailoverProperties {
private
String
primaryUrl
;
private
String
fallbackHost
;
private
String
fallbackUrl
;
private
String
model
;
private
String
modelKey
;
}
}
\ No newline at end of file
src/main/java/com/nanyan/securitylink/filter/FailoverGatewayFilterFactory.java
View file @
18300239
...
...
@@ -55,6 +55,8 @@ public class FailoverGatewayFilterFactory extends AbstractGatewayFilterFactory<F
uriConfig
.
getPrimaryUrl
(),
sourceUri
,
uriConfig
.
getPrimaryHost
(),
uriConfig
.
getModel
(),
uriConfig
.
getModelKey
(),
exchange
,
true
).
onErrorResume
(
primaryError
->
{
...
...
@@ -67,6 +69,8 @@ public class FailoverGatewayFilterFactory extends AbstractGatewayFilterFactory<F
uriConfig
.
getFallbackUrl
(),
targetUri
,
uriConfig
.
getFallbackHost
(),
uriConfig
.
getModel
(),
uriConfig
.
getModelKey
(),
exchange
,
false
);
...
...
@@ -109,7 +113,7 @@ public class FailoverGatewayFilterFactory extends AbstractGatewayFilterFactory<F
.
defaultIfEmpty
(
""
);
}
private
Mono
<
Void
>
tryRequest
(
String
baseUrl
,
String
uri
,
String
host
,
private
Mono
<
Void
>
tryRequest
(
String
baseUrl
,
String
uri
,
String
host
,
String
model
,
String
modelKey
,
ServerWebExchange
exchange
,
boolean
isSourceRequest
)
{
String
cachedBody
=
REQUEST_BODY_CACHE
.
get
();
ServerHttpRequest
request
=
exchange
.
getRequest
();
...
...
@@ -127,6 +131,8 @@ public class FailoverGatewayFilterFactory extends AbstractGatewayFilterFactory<F
requestBodySpec
.
headers
(
headers
->
{
headers
.
addAll
(
request
.
getHeaders
());
headers
.
set
(
HttpHeaders
.
HOST
,
host
);
headers
.
set
(
"model"
,
model
);
headers
.
set
(
"modelKey"
,
modelKey
);
});
// 设置请求体
...
...
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