Documentation ¶
Index ¶
- func AddLogField(rw http.ResponseWriter, name string, value string) error
- func ForceAddLogField(rw http.ResponseWriter, name string, value string)
- type HttpStatus
- type InvalidFieldError
- type LoggingResponseWriter
- func (l *LoggingResponseWriter) AddLogField(name string, value string) error
- func (l *LoggingResponseWriter) ForceAddLogField(name string, value string)
- func (rw *LoggingResponseWriter) GetResponseLog(r *http.Request, body string, elapsed time.Duration) *ResponseLog
- func (rw *LoggingResponseWriter) Status() int
- func (rw *LoggingResponseWriter) Write(body []byte) (int, error)
- func (rw *LoggingResponseWriter) WriteHeader(code int)
- type Request
- type RequestLog
- type Response
- type ResponseLog
- type Tags
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 ¶
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 RequestLog ¶
func GetRequestLog ¶
func GetRequestLog(r *http.Request, body string) *RequestLog
type ResponseLog ¶
type ResponseLog struct { HTTP HttpStatus `json:"http"` Request Request `json:"request"` Response Response `json:"response"` Tags Tags `json:"tags"` }
Click to show internal directories.
Click to hide internal directories.