Documentation ¶
Index ¶
- func LoggingMiddleware(next http.Handler) http.Handler
- func NewDumpMiddleware(dumpAction func(*RoundtripDump)) func(next http.Handler) http.Handler
- func NewDumpToLogMiddleware() func(next http.Handler) http.Handler
- func NewRequestHeaderWriteMiddlwware(headers map[string]string) func(next http.Handler) http.Handler
- func NewResponseHeaderWriteMiddlwware(headers map[string]string) func(next http.Handler) http.Handler
- type RequestDump
- type ResponseDump
- type ResponseSnifferingWriter
- type RoundtripDump
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LoggingMiddleware ¶
LoggingMiddleware prints the request URI.
func NewDumpMiddleware ¶
func NewDumpMiddleware(dumpAction func(*RoundtripDump)) func(next http.Handler) http.Handler
NewDumpMiddleware creates a new DumpMiddleware to call a function with the RoundtripDump objects.
func NewDumpToLogMiddleware ¶
NewDumpToLogMiddleware creates a new DumpMiddleware to log the RoundtripDump objects as serialised json string.
Types ¶
type RequestDump ¶
type RequestDump struct { Method string `json:"method"` Target string `json:"target"` Protocol string `json:"protocol"` Headers map[string][]string `json:"headers"` Body string `json:"body"` }
RequestDump - A RequestDump object represents an HTTP request. The HTTP method is stored as a string. The HTTP target url is stored as a string. The HTTP protocal, e.g. HTTP/HTTPS, is stored as a string. The HTTP headers are stored in a string-string map. The HTTP body is stored as a string.
type ResponseDump ¶
type ResponseDump struct { Headers map[string]string `json:"headers"` Body string `json:"body"` StatusCode int `json:"status_code"` }
ResponseDump - A ResponseDump object represents an HTTP response. The HTTP headers are stored in a string-string map. The HTTP body is stored as a string. The HTTP status code is stored as an integer.
type ResponseSnifferingWriter ¶
type ResponseSnifferingWriter struct { http.ResponseWriter MultiWriter io.Writer BytesBuffer *bytes.Buffer Status int }
ResponseSnifferingWriter overrides the logic of http.ResponseWriter to dump the full roundtrips of HTTP calls.
func NewResponseSnifferingWriter ¶
func NewResponseSnifferingWriter(realWriter http.ResponseWriter) ResponseSnifferingWriter
NewResponseSnifferingWriter initiates a ResponseSnifferingWriter object.
func (*ResponseSnifferingWriter) Header ¶
func (w *ResponseSnifferingWriter) Header() http.Header
Header overrides the logic of http.ResponseWriter.Header()
func (*ResponseSnifferingWriter) Write ¶
func (w *ResponseSnifferingWriter) Write(b []byte) (n int, err error)
Write overrides the logic of http.ResponseWriter.Write()
func (*ResponseSnifferingWriter) WriteHeader ¶
func (w *ResponseSnifferingWriter) WriteHeader(status int)
WriteHeader overrides the logic of http.ResponseWriter.WriteHeader()
type RoundtripDump ¶
type RoundtripDump struct { Timestamp time.Time `json:"timestamp"` Request RequestDump `json:"request"` Response ResponseDump `json:"response"` }
RoundtripDump - A RoundtripDump object represents a full roundtrip of an HTTP call.