Skip to content

Commit 6fc8edc

Browse files
committed
logger keys fix
1 parent a2aba9d commit 6fc8edc

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

context/keys/keys.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,15 +21,15 @@ const (
2121
IPAddressStr = "IP-Address"
2222
)
2323

24-
func GetAsString(ctx context.Context, key ContextKey) string {
24+
func GetAsString(ctx context.Context, key any) string {
2525
val, ok := ctx.Value(key).(string)
2626
if ok {
2727
return val
2828
}
2929
return ""
3030
}
3131

32-
func GetCtxValue(ctx context.Context, key ContextKey) any {
32+
func GetCtxValue(ctx context.Context, key any) any {
3333
return ctx.Value(key)
3434
}
3535

server/middleware/logger.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ func SetLogger(next echo.HandlerFunc) echo.HandlerFunc {
1212
return func(c echo.Context) error {
1313
// get request's context
1414
ctx := c.Request().Context()
15-
ipAddress, _ := keys.GetAsString(ctx, keys.IPAddressStr)
16-
identityID, _ := keys.GetAsString(ctx, keys.IdentityID)
17-
requestID, _ := keys.GetAsString(ctx, keys.RequestID)
18-
msgID, _ := keys.GetAsString(ctx, keys.MSGID)
15+
ipAddress := keys.GetAsString(ctx, keys.IPAddressStr)
16+
identityID := keys.GetAsString(ctx, keys.IdentityID)
17+
requestID := keys.GetAsString(ctx, keys.RequestID)
18+
msgID := keys.GetAsString(ctx, keys.MSGID)
1919

2020
logInfo := logger.ServiceContext{
2121
Service: verser.GetService(),

0 commit comments

Comments
 (0)