Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
ai-api-mgr
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
Odysseus
ai-api-mgr
Commits
1e85ff71
Commit
1e85ff71
authored
Mar 18, 2024
by
Cloud User
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
log http request id
parent
c1877c32
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
0 deletions
+21
-0
go.mod
go.mod
+1
-0
go.sum
go.sum
+2
-0
main.go
main.go
+18
-0
No files found.
go.mod
View file @
1e85ff71
...
...
@@ -52,6 +52,7 @@ require (
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/hashicorp/go-uuid v1.0.3 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/jcmturner/aescts/v2 v2.0.0 // indirect
github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect
github.com/jcmturner/gofork v1.7.6 // indirect
...
...
go.sum
View file @
1e85ff71
...
...
@@ -749,6 +749,8 @@ github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ
github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8=
github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc=
github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4=
github.com/hashicorp/golang-lru/v2 v2.0.7 h1:a+bsQ5rvGLjzHuww6tVxozPZFVghXaHOwFs4luLUK2k=
github.com/hashicorp/golang-lru/v2 v2.0.7/go.mod h1:QeFd9opnmA6QUJc5vARoKUSoFhyfM2/ZepoAG6RGpeM=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64=
github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ=
...
...
main.go
View file @
1e85ff71
...
...
@@ -73,6 +73,7 @@ var producerMessagesBytes = make(chan bytesAndHeader, 1000)
var
consumerMessages
=
make
(
chan
string
)
const
TaskIdAtrr
=
"Task-Id"
const
RequestId
=
"Request_Id"
func
kafkaProducerBytes
()
{
...
...
@@ -1003,10 +1004,27 @@ func ApiOrJWT(c *fiber.Ctx) error {
reqHeaders
:=
c
.
GetReqHeaders
()
if
taskHeaders
,
ok
:=
reqHeaders
[
TaskIdAtrr
];
ok
{
if
taskHeaders
==
nil
||
len
(
taskHeaders
)
==
0
{
return
c
.
SendString
(
fmt
.
Sprintf
(
"Please provide http header %s value, right now the value is %v."
,
TaskIdAtrr
,
taskHeaders
))
}
}
else
{
return
c
.
SendString
(
fmt
.
Sprintf
(
"Please provide http header %s ."
,
TaskIdAtrr
))
}
if
RequestIdHeaders
,
ok
:=
reqHeaders
[
RequestId
];
ok
{
if
RequestIdHeaders
==
nil
||
len
(
RequestIdHeaders
)
==
0
{
return
c
.
SendString
(
fmt
.
Sprintf
(
"Please provide http header %s value, right now the value is %v."
,
RequestId
,
RequestIdHeaders
))
}
}
else
{
return
c
.
SendString
(
fmt
.
Sprintf
(
"Please provide http header %s ."
,
RequestId
))
}
slogfiber
.
AddCustomAttributes
(
c
,
slog
.
String
(
TaskIdAtrr
,
reqHeaders
[
TaskIdAtrr
][
0
]))
baseAttributes
:=
[]
slog
.
Attr
{}
baseAttributes
=
append
(
baseAttributes
,
slog
.
String
(
TaskIdAtrr
,
reqHeaders
[
TaskIdAtrr
][
0
]))
baseAttributes
=
append
(
baseAttributes
,
slog
.
String
(
RequestId
,
reqHeaders
[
RequestId
][
0
]))
newAttributes
:=
append
(
baseAttributes
,
slog
.
String
(
"match_path"
,
c
.
Route
()
.
Path
))
slog
.
LogAttrs
(
c
.
UserContext
(),
slog
.
LevelInfo
,
"new Api or JWT reuqest"
,
newAttributes
...
)
...
...
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