File tree Expand file tree Collapse file tree 4 files changed +7
-24
lines changed Expand file tree Collapse file tree 4 files changed +7
-24
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,7 @@ const (
18
18
RequestLogID
19
19
20
20
RequestIDStr = "X-Request-Id"
21
+ IPAddressStr = "IP-Address"
21
22
)
22
23
23
24
func GetAsString (ctx context.Context , key ContextKey ) string {
Load Diff This file was deleted.
Original file line number Diff line number Diff line change @@ -10,9 +10,9 @@ import (
10
10
func SetIPAddress (next echo.HandlerFunc ) echo.HandlerFunc {
11
11
return func (c echo.Context ) error {
12
12
ip := keys .GetIPAddress (c .Request ().Header )
13
- c .Set (keys .IPAddress , ip )
13
+ c .Set (keys .IPAddressStr , ip )
14
14
15
- ctx := context .WithValue (c .Request ().Context (), keys .IPAddress , ip )
15
+ ctx := context .WithValue (c .Request ().Context (), keys .IPAddressStr , ip )
16
16
c .SetRequest (c .Request ().WithContext (ctx ))
17
17
return next (c )
18
18
}
Original file line number Diff line number Diff line change @@ -12,10 +12,10 @@ func SetLogger(next echo.HandlerFunc) echo.HandlerFunc {
12
12
return func (c echo.Context ) error {
13
13
// get request's context
14
14
ctx := c .Request ().Context ()
15
- ipAddress , _ := c . Get ( keys .IPAddress ).( string )
16
- identityID , _ := keys .GetCtxValue (ctx , keys .IdentityID ).( string )
17
- requestID , _ := keys .GetCtxValue (ctx , keys .RequestID ).( string )
18
- msgID , _ := keys .GetCtxValue (ctx , keys .MSGID ).( string )
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 )
19
19
20
20
logInfo := logger.ServiceContext {
21
21
Service : verser .GetService (),
You can’t perform that action at this time.
0 commit comments