Help us shape the future of Go! Take the 2026 Go Developer Survey

httptracer

package
v1.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 14, 2023 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Overview

Package httptracer implements http tracing functionality

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPTracer

type HTTPTracer interface {
	Request(req *http.Request) error
	Response(res *http.Response) error
}

HTTPTracer provides callback hook mechanism for HTTP transport.

type RoundTripTrace

type RoundTripTrace struct {
	Trace     HTTPTracer        // User provides callback methods
	Transport http.RoundTripper // HTTP transport that needs to be intercepted
}

RoundTripTrace interposes HTTP transport requests and respsonses using HTTPTracer hooks

func GetNewTraceTransport

func GetNewTraceTransport(trace HTTPTracer, transport http.RoundTripper) RoundTripTrace

GetNewTraceTransport returns a traceable transport

Takes first argument a custom tracer which implements Response, Request() conforming to HTTPTracer interface. Another argument can be a default transport or a custom http.RoundTripper implementation

func (RoundTripTrace) RoundTrip

func (t RoundTripTrace) RoundTrip(req *http.Request) (res *http.Response, err error)

RoundTrip executes user provided request and response hooks for each HTTP call.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL