https://github.com/navid2zp/httptracer
Simple HTTP tracer in Go
https://github.com/navid2zp/httptracer
golang http httptracer trace tracer tracing
Last synced: 7 months ago
JSON representation
Simple HTTP tracer in Go
- Host: GitHub
- URL: https://github.com/navid2zp/httptracer
- Owner: Navid2zp
- License: mit
- Created: 2019-07-20T21:15:10.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-09-05T10:34:32.000Z (about 5 years ago)
- Last Synced: 2025-01-20T15:32:11.247Z (9 months ago)
- Topics: golang, http, httptracer, trace, tracer, tracing
- Language: Go
- Homepage:
- Size: 7.81 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# httptracer
Simple HTTP tracer using builtin `httptrace` package.
## Install/Update
```
go get -u github.com/Navid2zp/httptracer
```### Example
```go
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.
```go
// Returns json encoded bytes
jsonData, _ := result.ToJSON()
fmt.Println(string(jsonData))// Returns xml encoded bytes
xmlData, _ := result.ToXML()
fmt.Println(string(xmlData))
```