@@ -15,18 +15,18 @@ import (
15
15
// Return (key, true) to use the provided key; return ("", false) to fall back to the default UUID key.
16
16
type RequestKeyFunc func (r * http.Request ) (string , bool )
17
17
18
- // AddRequestScopedClient returns a net/http middleware that, for each incoming request,
18
+ // AddScopedClientForRequest returns a net/http middleware that, for each incoming request,
19
19
// creates an LDScopedClient seeded with a `request`-kind LDContext populated with useful
20
20
// HTTP request attributes (e.g., method, path, host, userAgent), and stores it in the
21
21
// request's Go context. Downstream handlers can retrieve it via ld.GetScopedClient.
22
- func AddRequestScopedClient (client * ld.LDClient ) func (next http.Handler ) http.Handler {
23
- return AddRequestScopedClientWithKeyFn (client , nil )
22
+ func AddScopedClientForRequest (client * ld.LDClient ) func (next http.Handler ) http.Handler {
23
+ return AddScopedClientForRequestWithKeyFn (client , nil )
24
24
}
25
25
26
- // AddRequestScopedClientWithKeyFn is like AddRequestScopedClient , but allows providing a function to override
26
+ // AddScopedClientForRequestWithKeyFn is like AddScopedClientForRequest , but allows providing a function to override
27
27
// the context key used for the `request`-kind LDContext. If the function returns ok=false or an empty key,
28
28
// a random UUID will be used.
29
- func AddRequestScopedClientWithKeyFn (client * ld.LDClient , keyFn RequestKeyFunc ) func (next http.Handler ) http.Handler {
29
+ func AddScopedClientForRequestWithKeyFn (client * ld.LDClient , keyFn RequestKeyFunc ) func (next http.Handler ) http.Handler {
30
30
return func (next http.Handler ) http.Handler {
31
31
return http .HandlerFunc (func (w http.ResponseWriter , r * http.Request ) {
32
32
// Determine request context key
@@ -62,8 +62,8 @@ func AddRequestScopedClientWithKeyFn(client *ld.LDClient, keyFn RequestKeyFunc)
62
62
}
63
63
64
64
// TrackTiming sends a LD event "http.request.duration_ms" with the duration of the request in milliseconds.
65
- // This middleware must be after AddRequestScopedClient in the middleware chain, as it uses the scoped client
66
- // from the request context.
65
+ // This middleware must be after AddScopedClientForRequest in the middleware chain, as it uses the scoped client
66
+ // from the Go context.
67
67
//
68
68
// The timing event will include all LaunchDarkly contexts added to the scoped client. You may add more
69
69
// contexts to the scoped client _during_ the request, and they will be included in the timing event sent
@@ -82,8 +82,8 @@ func TrackTiming(next http.Handler) http.Handler {
82
82
}
83
83
84
84
// TrackErrorResponses sends a LD event "http.response.4xx" or "http.response.5xx" if the response code is 4xx or 5xx.
85
- // This middleware must be after AddRequestScopedClient in the middleware chain, as it uses the scoped client
86
- // from the request context.
85
+ // This middleware must be after AddScopedClientForRequest in the middleware chain, as it uses the scoped client
86
+ // from the Go context.
87
87
//
88
88
// The error event will include all LaunchDarkly contexts added to the scoped client. You may add more
89
89
// contexts to the scoped client _during_ the request, and they will be included in the error event sent
0 commit comments