-
Notifications
You must be signed in to change notification settings - Fork 3
/
meta.go
35 lines (27 loc) · 783 Bytes
/
meta.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package meta
import (
"context"
"github.com/alexfalkowski/go-service/meta"
)
const (
// RequestIDKey for meta.
RequestIDKey = "transport.request_id"
// UserAgentKey for meta.
UserAgentKey = "transport.user_agent"
)
// WithRequestID for transport.
func WithRequestID(ctx context.Context, id string) context.Context {
return meta.WithAttribute(ctx, RequestIDKey, id)
}
// RequestID for transport.
func RequestID(ctx context.Context) string {
return meta.Attribute(ctx, RequestIDKey)
}
// WithUserAgent for transport.
func WithUserAgent(ctx context.Context, userAgent string) context.Context {
return meta.WithAttribute(ctx, UserAgentKey, userAgent)
}
// UserAgent for transport.
func UserAgent(ctx context.Context) string {
return meta.Attribute(ctx, UserAgentKey)
}