httprecorder

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HTTPRecorder

type HTTPRecorder struct {
	// contains filtered or unexported fields
}

func NewRecorder

func NewRecorder(inner http.RoundTripper, log *RequestLog) *HTTPRecorder

func (*HTTPRecorder) RoundTrip

func (m *HTTPRecorder) RoundTrip(request *http.Request) (*http.Response, error)

type LogEntry

type LogEntry struct {
	Request  Request  `json:"request,omitempty"`
	Response Response `json:"response,omitempty"`
	Error    string   `json:"error,omitempty"`
}

func (*LogEntry) FormatHTTP

func (e *LogEntry) FormatHTTP() string

type Request

type Request struct {
	Method string      `json:"method,omitempty"`
	URL    string      `json:"url,omitempty"`
	Header http.Header `json:"header,omitempty"`
	Body   string      `json:"body,omitempty"`
}

func (*Request) FormatHTTP

func (r *Request) FormatHTTP() string

type RequestLog

type RequestLog struct {
	Entries []LogEntry
}

func (*RequestLog) FormatHTTP

func (l *RequestLog) FormatHTTP() string

func (*RequestLog) RemoveHeader

func (l *RequestLog) RemoveHeader(k string)

func (*RequestLog) RemoveUserAgent

func (l *RequestLog) RemoveUserAgent()

func (*RequestLog) ReplaceURLPrefix

func (l *RequestLog) ReplaceURLPrefix(old, new string)

type Response

type Response struct {
	Status     string      `json:"status,omitempty"`
	StatusCode int         `json:"statusCode,omitempty"`
	Header     http.Header `json:"header,omitempty"`
	Body       string      `json:"body,omitempty"`
}

func (*Response) FormatHTTP

func (r *Response) FormatHTTP() string

Jump to

Keyboard shortcuts

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