httptracer

package module
v0.0.0-...-e21b581 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2020 License: MIT Imports: 9 Imported by: 1

README

httptracer

Simple HTTP tracer using builtin httptrace package.

Install/Update

go get -u github.com/Navid2zp/httptracer
Example
result, err := httptracer.Trace("https://google.com", "GET")

fmt.Println("Error: ", err)

fmt.Println("Name Lookup: ", result.NameLookup)
fmt.Println("Connect: ", result.Connect)
fmt.Println("TLS Handshake: ", result.TLSHandshake)
fmt.Println("First Byte: ", result.FirstByte)
fmt.Println("Full Response: ", result.FullResponse)
fmt.Println("Body Size (byte): ", result.BodySize)
Methods

You can convert results to JSON or XML easier using these methods.

// Returns json encoded bytes
jsonData, _ := result.ToJSON()
fmt.Println(string(jsonData))

// Returns xml encoded bytes
xmlData, _ := result.ToXML()
fmt.Println(string(xmlData))

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type TracerResult

type TracerResult struct {
	NameLookup   time.Duration `json:"name_lookup" xml:"name_lookup"`
	Connect      time.Duration `json:"connect" xml:"connect"`
	TLSHandshake time.Duration `json:"tls_handshake" xml:"tls_handshake"`
	FirstByte    time.Duration `json:"first_byte" xml:"first_byte"`
	FullResponse time.Duration `json:"full_response" xml:"full_response"`
	BodySize     int           `json:"body_size" xml:"body_size"`
}

func Trace

func Trace(url, method string) (*TracerResult, error)

func Tracer

func Tracer(url, method string) (*TracerResult, error)

func (*TracerResult) ToJSON

func (d *TracerResult) ToJSON() ([]byte, error)

func (*TracerResult) ToXML

func (d *TracerResult) ToXML() ([]byte, error)

Jump to

Keyboard shortcuts

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