예제 #1
0
파일: weblogs.go 프로젝트: koofr/weblogs
// Values returns the current key-value pairs to be logged.
// If the handler calling this is not wrapped by the Handler() method,
// then this method returns nil.
func Values(r *http.Request) map[interface{}]interface{} {
	instance := context.Get(r, kValuesKey)
	if instance == nil {
		return nil
	}
	return instance.(map[interface{}]interface{})
}
예제 #2
0
파일: weblogs.go 프로젝트: koofr/weblogs
// Writer returns a writer whereby the caller can add additional information
// to the current log entry. If the handler calling this is not wrapped by
// the Handler() method, then writing to the returned io.Writer does
// nothing.
func Writer(r *http.Request) io.Writer {
	value := context.Get(r, kBufferKey)
	if value == nil {
		return nilWriter{}
	}
	return value.(*bytes.Buffer)
}