Skip to content

Commit 0e07729

Browse files
committed
rename fns
1 parent 58d96bb commit 0e07729

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

ldmiddleware/http_middleware.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@ import (
1515
// Return (key, true) to use the provided key; return ("", false) to fall back to the default UUID key.
1616
type RequestKeyFunc func(r *http.Request) (string, bool)
1717

18-
// AddRequestScopedClient returns a net/http middleware that, for each incoming request,
18+
// AddScopedClientForRequest returns a net/http middleware that, for each incoming request,
1919
// creates an LDScopedClient seeded with a `request`-kind LDContext populated with useful
2020
// HTTP request attributes (e.g., method, path, host, userAgent), and stores it in the
2121
// 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)
2424
}
2525

26-
// AddRequestScopedClientWithKeyFn is like AddRequestScopedClient, but allows providing a function to override
26+
// AddScopedClientForRequestWithKeyFn is like AddScopedClientForRequest, but allows providing a function to override
2727
// the context key used for the `request`-kind LDContext. If the function returns ok=false or an empty key,
2828
// 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 {
3030
return func(next http.Handler) http.Handler {
3131
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
3232
// Determine request context key
@@ -62,8 +62,8 @@ func AddRequestScopedClientWithKeyFn(client *ld.LDClient, keyFn RequestKeyFunc)
6262
}
6363

6464
// 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.
6767
//
6868
// The timing event will include all LaunchDarkly contexts added to the scoped client. You may add more
6969
// 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 {
8282
}
8383

8484
// 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.
8787
//
8888
// The error event will include all LaunchDarkly contexts added to the scoped client. You may add more
8989
// contexts to the scoped client _during_ the request, and they will be included in the error event sent

0 commit comments

Comments
 (0)