Documentation
¶
Overview ¶
Package harhar provides a minimal set of methods and structs to enable HAR logging in a go net/http-based application.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Creator ¶
type Creator struct {
// Name defaults to the name of the program (os.Args[0])
Name string `json:"name"`
// Version defaults to the current time (formatted as "20060102150405")
Version string `json:"version"`
}
Creator describes the source of the logged requests/responses.
type Entry ¶
type Entry struct {
Request Request `json:"request"`
Response Response `json:"response"`
Start string `json:"startedDateTime"` // ISO8601 time
// Total time in milliseconds, Time=SUM(Timings.*)
Time int `json:"time"`
Timings struct {
Send int `json:"send"`
Wait int `json:"wait"`
Receive int `json:"receive"`
} `json:"timings"`
// always empty
Cache map[string]string `json:"cache"`
}
type Log ¶
type Log struct {
Creator Creator `json:"creator"`
// Version defaults to the current time (formatted as "20060102150405")
Version string `json:"version"`
// Comment can be added to the log to describe the particulars of this data.
Comment string `json:"comment,omitempty"`
// Entries contains all of the Request and Response details that passed
// through this Client.
Entries []Entry `json:"entries"`
}
type NameValuePair ¶
type Recorder ¶
type Recorder struct {
http.RoundTripper `json:"-"`
HAR *HAR
}
Client embeds an upstream RoundTripper and wraps its methods to perform transparent HAR logging for every request and response
func NewRecorder ¶
func NewRecorder() *Recorder
NewRecorder returns a new Recorder object that fulfills the http.RoundTripper interface
type Request ¶
type Request struct {
Method string `json:"method"` // in caps, GET/POST/etc
URL string `json:"url"`
HttpVersion string `json:"httpVersion"` // ex "HTTP/1.1"
Headers []NameValuePair `json:"headers"`
Cookies []Cookie `json:"cookies"`
QueryParams []NameValuePair `json:"queryString"`
Body struct {
MIMEType string `json:"mimeType"`
Content string `json:"text"`
} `json:"postData"`
// always -1, too lazy
HeadersSize int `json:"headersSize"`
BodySize int `json:"bodySize"`
}
type Response ¶
type Response struct {
StatusCode int `json:"status"` // 200
StatusText string `json:"statusText"` // "OK"
HttpVersion string `json:"httpVersion"` // ex "HTTP/1.1"
RedirectURL string `json:"redirectURL"`
Headers []NameValuePair `json:"headers"`
Cookies []Cookie `json:"cookies"`
Body struct {
Size int `json:"size"`
MIMEType string `json:"mimeType"`
Content string `json:"text"`
} `json:"content"`
// always -1, too lazy
HeadersSize int `json:"headersSize"`
BodySize int `json:"bodySize"`
}
Click to show internal directories.
Click to hide internal directories.