lrw

package
v0.0.0-...-bf09d72 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2020 License: Apache-2.0 Imports: 3 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddLogField

func AddLogField(rw http.ResponseWriter, name string, value string) error

AddLogField will attempt to add the log field to the response writer, if it is not a LoggingResponseWriter then it will turn the ResponseWriter into one

func ForceAddLogField

func ForceAddLogField(rw http.ResponseWriter, name string, value string)

ForceAddLogField will always to add the log field to the response writer and ovewrite any field that may already exist if it is not a LoggingResponseWriter then it will turn the ResponseWriter into one

Types

type HttpStatus

type HttpStatus struct {
	StatusCode int `json:"status_code"`
}

type InvalidFieldError

type InvalidFieldError struct {
	InvalidField string
	Message      string
}

func (*InvalidFieldError) Error

func (ife *InvalidFieldError) Error() string

type LoggingResponseWriter

type LoggingResponseWriter struct {
	http.ResponseWriter
	StatusCode  int
	InnerError  error
	ExtraFields map[string]string
	WroteHeader bool
	Body        []byte
}

func NewLoggingResponseWriter

func NewLoggingResponseWriter(rw http.ResponseWriter) *LoggingResponseWriter

func (*LoggingResponseWriter) AddLogField

func (l *LoggingResponseWriter) AddLogField(name string, value string) error

AddLogField will attempt to add the field to the logs that will emitted for each request, it will fail if it attempts to override another field

func (*LoggingResponseWriter) ForceAddLogField

func (l *LoggingResponseWriter) ForceAddLogField(name string, value string)

ForceAddLogField will always add the log field and will overwrite anything that may currently exist as a field already

func (*LoggingResponseWriter) GetResponseLog

func (rw *LoggingResponseWriter) GetResponseLog(r *http.Request, body string, elapsed time.Duration) *ResponseLog

func (*LoggingResponseWriter) Status

func (rw *LoggingResponseWriter) Status() int

func (*LoggingResponseWriter) Write

func (rw *LoggingResponseWriter) Write(body []byte) (int, error)

func (*LoggingResponseWriter) WriteHeader

func (rw *LoggingResponseWriter) WriteHeader(code int)

type Request

type Request struct {
	Header http.Header `json:"headers"`
	Body   string      `json:"body"`
}

type RequestLog

type RequestLog struct {
	Request Request `json:"request"`
	Tags    Tags    `json:"tags"`
}

func GetRequestLog

func GetRequestLog(r *http.Request, body string) *RequestLog

type Response

type Response struct {
	Header http.Header   `json:"headers"`
	Body   string        `json:"body"`
	Time   time.Duration `json:"time"`
}

type ResponseLog

type ResponseLog struct {
	HTTP     HttpStatus `json:"http"`
	Request  Request    `json:"request"`
	Response Response   `json:"response"`
	Tags     Tags       `json:"tags"`
}

type Tags

type Tags struct {
	Method  string `json:"method"`
	BaseURL string `json:"baseUrl"`
	URL     string `json:"url"`
	Type    string `json:"type"`
}

Jump to

Keyboard shortcuts

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