clihttp

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2021 License: MIT Imports: 10 Imported by: 1

Documentation

Overview

Package clihttp adds opentracing support to http client.

Example
client := NewClient(opentracing.GlobalTracer())
req, _ := http.NewRequest("GET", "https://example.com/", nil)
resp, _ := client.Do(req)
resp.Body.Close()
Output:

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a http client that traces http requests.

func NewClient

func NewClient(tracer opentracing.Tracer, options ...Option) *Client

NewClient creates a Client with tracing support.

func (*Client) Do

func (c *Client) Do(req *http.Request) (*http.Response, error)

Do sends the request.

type HttpDoer

type HttpDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

HttpDoer modules a upstream http client.

type Option

type Option func(*Client)

Option changes the behavior of Client.

func WithDoer

func WithDoer(doer contract.HttpDoer) Option

WithDoer is an option that accepts a HttpDoer as the underlying client.

func WithRequestLogThreshold

func WithRequestLogThreshold(num int) Option

WithRequestLogThreshold is options that sets threshold of request logging in number of bytes. If the payload is larger than this threshold, the log will be omit.

func WithResponseLogThreshold

func WithResponseLogThreshold(num int) Option

WithResponseLogThreshold is options that sets threshold of response logging in number of bytes. If the response body is larger than this threshold, the log will be omit.

Jump to

Keyboard shortcuts

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