Пример #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)
		},
	}
}
Пример #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
}
Пример #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
}