Example #1
0
// NewLogger returns a logger that logs requests and responses. Log function defaults to martian.Infof.
func NewLogger() *Logger {
	return &Logger{
		log: func(line string) {
			martian.Infof(line)
		},
	}
}
Example #2
0
// ModifyResponse sets cookie on the response.
func (m *modifier) ModifyResponse(res *http.Response) error {
	res.Header.Add("Set-Cookie", m.cookie.String())
	martian.Infof("%s: add cookie: %s", res.Request.URL, m.cookie)

	return nil
}
Example #3
0
// ModifyRequest adds cookie to the request.
func (m *modifier) ModifyRequest(req *http.Request) error {
	req.AddCookie(m.cookie)
	martian.Infof("%s: add cookie: %s", req.URL, m.cookie)

	return nil
}