Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
893104a1
authored
Aug 15, 2025
by
CaIon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor: move anthropicKey retrieval to improve authorization handling
parent
8284cff9
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 additions
and
4 deletions
+1
-4
middleware/auth.go
+1
-4
No files found.
middleware/auth.go
View file @
893104a1
...
@@ -192,12 +192,9 @@ func TokenAuth() func(c *gin.Context) {
...
@@ -192,12 +192,9 @@ func TokenAuth() func(c *gin.Context) {
}
}
c
.
Request
.
Header
.
Set
(
"Authorization"
,
"Bearer "
+
key
)
c
.
Request
.
Header
.
Set
(
"Authorization"
,
"Bearer "
+
key
)
}
}
anthropicKey
:=
c
.
Request
.
Header
.
Get
(
"x-api-key"
)
// 检查path包含/v1/messages
// 检查path包含/v1/messages
// 或者是否 x-api-key 不为空且存在anthropic-version
// 谁知道有多少不符合规范没写anthropic-version的
// 所以就这样随它去吧(
if
strings
.
Contains
(
c
.
Request
.
URL
.
Path
,
"/v1/messages"
)
{
if
strings
.
Contains
(
c
.
Request
.
URL
.
Path
,
"/v1/messages"
)
{
anthropicKey
:=
c
.
Request
.
Header
.
Get
(
"x-api-key"
)
if
anthropicKey
!=
""
{
if
anthropicKey
!=
""
{
c
.
Request
.
Header
.
Set
(
"Authorization"
,
"Bearer "
+
anthropicKey
)
c
.
Request
.
Header
.
Set
(
"Authorization"
,
"Bearer "
+
anthropicKey
)
}
}
...
...
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