Documentation
¶
Index ¶
- func CORSMiddleware(next http.Handler) http.Handler
- func InitDefaultLogger()
- func RecoverPanicMiddleware(h http.Handler) http.Handler
- func RequestLoggerMiddleware(next http.Handler) http.Handler
- func SetLogger(l interface{})
- type ReqRespLogStruct
- type RequestStruct
- type ResponseStruct
- type ResponseWriterWrapper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CORSMiddleware ¶
CORSMiddleware function sets the headers for the response and returns directly if there is an OPTIONS request
func InitDefaultLogger ¶
func InitDefaultLogger()
InitDefaultLogger sets the default logger to "github.com/gyozatech/noodlog" is no other logger has been set
func RequestLoggerMiddleware ¶
RequestLoggerMiddleware is the middleware layer to log all the HTTP requests
Types ¶
type ReqRespLogStruct ¶
type ReqRespLogStruct struct { Request RequestStruct ExecTime time.Duration Response ResponseStruct }
ReqRespLogStruct struct represents the schema for the HTTP Request/ExecutionTime/Response log
type RequestStruct ¶
type RequestStruct struct { Verb string `json:"verb,omitempty"` Path string `json:"path,omitempty"` Protocol string `json:"protocol,omitempty"` Headers map[string]string `json:"headers,omitempty"` Body interface{} `json:"body,omitempty"` }
RequestStruct struct represents the schema for the HTTP Request log
func HTTPRequest ¶
func HTTPRequest(r *http.Request) RequestStruct
HTTPRequest static function flatten pointers of HTTP Request and obscurate passwords to prepare for logging
type ResponseStruct ¶
type ResponseStruct struct { Status int `json:"status,omitempty"` Headers map[string]string `json:"headers,omitempty"` Body interface{} `json:"body,omitempty"` }
ResponseStruct struct represents the schema for the HTTP Response log
func HTTPResponse ¶
func HTTPResponse(statusCode int, responseHeaders http.Header, requestURI string, responseBody string) ResponseStruct
HTTPResponse static function flatten pointers of HTTP Response and obscurate passwords to prepare for logging
type ResponseWriterWrapper ¶
type ResponseWriterWrapper struct {
// contains filtered or unexported fields
}
ResponseWriterWrapper struct is used to log the response
func NewResponseWriterWrapper ¶
func NewResponseWriterWrapper(w *http.ResponseWriter, r *http.Request) ResponseWriterWrapper
NewResponseWriterWrapper static function creates a wrapper for the http.ResponseWriter
func (ResponseWriterWrapper) Header ¶
func (rww ResponseWriterWrapper) Header() http.Header
Header function overwrites the http.ResponseWriter Header() function
func (ResponseWriterWrapper) Hijack ¶ added in v0.1.8
func (rww ResponseWriterWrapper) Hijack() (net.Conn, *bufio.ReadWriter, error)
Hijack allows the ResponseWriterWrapper to implement the http.Hijacker interface necessary to upgrade the connection to a WebSocket
func (ResponseWriterWrapper) Write ¶
func (rww ResponseWriterWrapper) Write(buf []byte) (int, error)
func (ResponseWriterWrapper) WriteHeader ¶
func (rww ResponseWriterWrapper) WriteHeader(statusCode int)
WriteHeader function overwrites the http.ResponseWriter WriteHeader() function