Browse Source
Added middleware for processing request_id grpc and http requests (#6805)
pull/6808/head
Added middleware for processing request_id grpc and http requests (#6805)
pull/6808/head
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 88 additions and 21 deletions
-
26weed/pb/grpc_client_server.go
-
21weed/server/common.go
-
8weed/server/filer_server.go
-
24weed/server/master_server.go
-
10weed/server/volume_server.go
-
20weed/util/request_id.go
@ -0,0 +1,20 @@ |
|||
package util |
|||
|
|||
import "context" |
|||
|
|||
const ( |
|||
RequestIdHttpHeader = "X-Request-ID" |
|||
RequestIDKey = "x-request-id" |
|||
) |
|||
|
|||
func GetRequestID(ctx context.Context) string { |
|||
if ctx == nil { |
|||
return "" |
|||
} |
|||
id, _ := ctx.Value(RequestIDKey).(string) |
|||
return id |
|||
} |
|||
|
|||
func WithRequestID(ctx context.Context, id string) context.Context { |
|||
return context.WithValue(ctx, RequestIDKey, id) |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue