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
822fca34
Commit
822fca34
authored
Mar 18, 2024
by
Cloud User
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fiber http log
parent
05c4dd99
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
2 deletions
+26
-2
main.go
main.go
+26
-2
No files found.
main.go
View file @
822fca34
...
@@ -915,10 +915,10 @@ func main() {
...
@@ -915,10 +915,10 @@ func main() {
//app := fiber.New()
//app := fiber.New()
//app.Use(slogfiber.NewWithConfig(slog.Default(), cfg))
//app.Use(slogfiber.NewWithConfig(slog.Default(), cfg))
app
.
Use
(
slogfiber
.
New
(
slog
.
Default
()))
//
app.Use(slogfiber.New(slog.Default()))
//app.Use(recover.New())
//app.Use(recover.New())
//
app.Use(slogfiber.New(slog.Default()))
app
.
Use
(
slogfiber
.
New
(
slog
.
Default
()))
app
.
Use
(
recover
.
New
())
app
.
Use
(
recover
.
New
())
apiGroup
:=
app
.
Group
(
"/api"
)
apiGroup
:=
app
.
Group
(
"/api"
)
...
@@ -928,16 +928,34 @@ func main() {
...
@@ -928,16 +928,34 @@ func main() {
apiGroupV1
.
Post
(
"/*"
,
ApiOrJWT
)
apiGroupV1
.
Post
(
"/*"
,
ApiOrJWT
)
jwtGroupV1
:=
jwtGroup
.
Group
(
"/v1"
)
jwtGroupV1
:=
jwtGroup
.
Group
(
"/v1"
)
//jwtGroupV1.Post("/*", slogfiber.New(slog.Default()), ApiOrJWT)
jwtGroupV1
.
Post
(
"/*"
,
ApiOrJWT
)
jwtGroupV1
.
Post
(
"/*"
,
ApiOrJWT
)
//curl -X GET http://127.0.0.1:4000/api/jobs?id=e45b5ebc-c71e-4ab8-b10f-d1202e7fb16e
//curl -X GET http://127.0.0.1:4000/api/jobs?id=e45b5ebc-c71e-4ab8-b10f-d1202e7fb16e
//slogfiber.NewWithConfig(slog.Default(), cfg)
queryGroup
:=
app
.
Group
(
"/query"
)
queryGroup
:=
app
.
Group
(
"/query"
)
queryGroupV1
:=
queryGroup
.
Group
(
"/v1"
)
queryGroupV1
:=
queryGroup
.
Group
(
"/v1"
)
queryGroupV1
.
Get
(
"/:taskId"
,
func
(
c
*
fiber
.
Ctx
)
error
{
queryGroupV1
.
Get
(
"/:taskId"
,
func
(
c
*
fiber
.
Ctx
)
error
{
taskId
:=
c
.
Params
(
"taskId"
)
taskId
:=
c
.
Params
(
"taskId"
)
slogfiber
.
AddCustomAttributes
(
c
,
slog
.
String
(
TaskIdAtrr
,
taskId
))
reqHeaders
:=
c
.
GetReqHeaders
()
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
(
RequestId
,
reqHeaders
[
RequestId
][
0
]))
baseAttributes
:=
[]
slog
.
Attr
{}
baseAttributes
:=
[]
slog
.
Attr
{}
baseAttributes
=
append
(
baseAttributes
,
slog
.
String
(
TaskIdAtrr
,
taskId
))
baseAttributes
=
append
(
baseAttributes
,
slog
.
String
(
TaskIdAtrr
,
taskId
))
...
@@ -992,6 +1010,8 @@ func main() {
...
@@ -992,6 +1010,8 @@ func main() {
return
c
.
SendString
(
fmt
.
Sprintf
(
"callback Unmarshal error %v"
,
err
.
Error
()))
return
c
.
SendString
(
fmt
.
Sprintf
(
"callback Unmarshal error %v"
,
err
.
Error
()))
}
}
slogfiber
.
AddCustomAttributes
(
c
,
slog
.
String
(
TaskIdAtrr
,
resbody
.
TaskId
))
baseAttributes
:=
[]
slog
.
Attr
{}
baseAttributes
:=
[]
slog
.
Attr
{}
baseAttributes
=
append
(
baseAttributes
,
slog
.
String
(
TaskIdAtrr
,
resbody
.
TaskId
))
baseAttributes
=
append
(
baseAttributes
,
slog
.
String
(
TaskIdAtrr
,
resbody
.
TaskId
))
...
@@ -1046,6 +1066,8 @@ func ApiOrJWT(c *fiber.Ctx) error {
...
@@ -1046,6 +1066,8 @@ func ApiOrJWT(c *fiber.Ctx) error {
return
c
.
SendString
(
fmt
.
Sprintf
(
"Please provide http header %s ."
,
TaskIdAtrr
))
return
c
.
SendString
(
fmt
.
Sprintf
(
"Please provide http header %s ."
,
TaskIdAtrr
))
}
}
slogfiber
.
AddCustomAttributes
(
c
,
slog
.
String
(
TaskIdAtrr
,
reqHeaders
[
TaskIdAtrr
][
0
]))
if
RequestIdHeaders
,
ok
:=
reqHeaders
[
RequestId
];
ok
{
if
RequestIdHeaders
,
ok
:=
reqHeaders
[
RequestId
];
ok
{
if
RequestIdHeaders
==
nil
||
len
(
RequestIdHeaders
)
==
0
{
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
))
return
c
.
SendString
(
fmt
.
Sprintf
(
"Please provide http header %s value, right now the value is %v."
,
RequestId
,
RequestIdHeaders
))
...
@@ -1054,6 +1076,8 @@ func ApiOrJWT(c *fiber.Ctx) error {
...
@@ -1054,6 +1076,8 @@ func ApiOrJWT(c *fiber.Ctx) error {
return
c
.
SendString
(
fmt
.
Sprintf
(
"Please provide http header %s ."
,
RequestId
))
return
c
.
SendString
(
fmt
.
Sprintf
(
"Please provide http header %s ."
,
RequestId
))
}
}
slogfiber
.
AddCustomAttributes
(
c
,
slog
.
String
(
RequestId
,
reqHeaders
[
RequestId
][
0
]))
//slogfiber.AddCustomAttributes(c, slog.String(TaskIdAtrr, reqHeaders[TaskIdAtrr][0]))
//slogfiber.AddCustomAttributes(c, slog.String(TaskIdAtrr, reqHeaders[TaskIdAtrr][0]))
baseAttributes
:=
[]
slog
.
Attr
{}
baseAttributes
:=
[]
slog
.
Attr
{}
...
...
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