Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bobgroup-go-utils
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Bob Public Utils
bobgroup-go-utils
Commits
211f3446
Commit
211f3446
authored
3 years ago
by
Jan Semmelink
Browse files
Options
Downloads
Patches
Plain Diff
Added CurrentRequestID to api.Context for legacy handlers
parent
90ec162f
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
api/api.go
+4
-0
4 additions, 0 deletions
api/api.go
api/lambda.go
+4
-0
4 additions, 0 deletions
api/lambda.go
with
8 additions
and
0 deletions
api/api.go
+
4
−
0
View file @
211f3446
...
@@ -18,6 +18,10 @@ import (
...
@@ -18,6 +18,10 @@ import (
"gitlab.com/uafrica/go-utils/service"
"gitlab.com/uafrica/go-utils/service"
)
)
//LEGACY: global variable is set only for backward compatibility
//When handlers are changed to accept context, they should get this from the context
var
CurrentRequestID
*
string
//New creates the API with the specified routes keys on [path][method]
//New creates the API with the specified routes keys on [path][method]
//value could be any of the handler function signatures supported by the api.Router
//value could be any of the handler function signatures supported by the api.Router
//requestIDHeaderKey is defined in the response header to match the requestID from the request
//requestIDHeaderKey is defined in the response header to match the requestID from the request
...
...
This diff is collapsed.
Click to expand it.
api/lambda.go
+
4
−
0
View file @
211f3446
...
@@ -113,6 +113,10 @@ func (api Api) Handler(baseCtx context.Context, apiGatewayProxyReq events.APIGat
...
@@ -113,6 +113,10 @@ func (api Api) Handler(baseCtx context.Context, apiGatewayProxyReq events.APIGat
rand
.
Seed
(
time
.
Now
()
.
Unix
())
rand
.
Seed
(
time
.
Now
()
.
Unix
())
//LEGACY: delete this as soon as all handlers accepts context
//this does not support concurrent execution!
CurrentRequestID
=
&
ctx
.
Request
.
RequestContext
.
RequestID
ctx
.
Debugf
(
"HTTP %s %s ...
\n
"
,
apiGatewayProxyReq
.
HTTPMethod
,
apiGatewayProxyReq
.
Resource
)
ctx
.
Debugf
(
"HTTP %s %s ...
\n
"
,
apiGatewayProxyReq
.
HTTPMethod
,
apiGatewayProxyReq
.
Resource
)
ctx
.
WithFields
(
map
[
string
]
interface
{}{
ctx
.
WithFields
(
map
[
string
]
interface
{}{
"http_method"
:
ctx
.
Request
.
HTTPMethod
,
"http_method"
:
ctx
.
Request
.
HTTPMethod
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment