Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CorrelationId ¶
func CorrelationId(options ...correlation_id.Option) httpware.Tripperware
CorrelationId is a decoration of CorrelationId(github.com/gol4ng/httpware/v2/tripperware) it will add correlationId to gol4ng/logger context this tripperware require request context with a WrappableLoggerInterface in order to properly add correlationID to the logger context eg:
stack := httpware.TripperwareStack( tripperware.InjectLogger(l), // << Inject logger before CorrelationId tripperware.CorrelationId(), )
OR
ctx := logger.InjectInContext(context.Background(), yourWrappableLogger) req, _ := http.NewRequestWithContext(ctx, http.MethodGet, "http://a.zz.fr", nil) http.Client{}.Do(req)
Example ¶
myLogger := logger.NewNopLogger() clientStack := httpware.TripperwareStack( tripperware.InjectLogger(myLogger), tripperware.CorrelationId( correlation_id.WithHeaderName("my-personal-header-name"), correlation_id.WithIdGenerator(func(request *http.Request) string { return "my-fixed-request-id" }), ), ) c := http.Client{ Transport: clientStack.DecorateRoundTripper(http.DefaultTransport), } c.Get("http://google.com")
Output:
func InjectLogger ¶
func InjectLogger(log logger.LoggerInterface) httpware.Tripperware
InjectLogger will inject logger on request context if not exist
func Logger ¶
func Logger(log logger.LoggerInterface, opts ...logger_http.Option) func(next http.RoundTripper) http.RoundTripper
Logger will decorate the http.Client to add support of gol4ng/logger
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.