示例#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)
}