本文整理匯總了Golang中github.com/zenazn/goji/web/mutil.WriterProxy.Status方法的典型用法代碼示例。如果您正苦於以下問題:Golang WriterProxy.Status方法的具體用法?Golang WriterProxy.Status怎麽用?Golang WriterProxy.Status使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/zenazn/goji/web/mutil.WriterProxy
的用法示例。
在下文中一共展示了WriterProxy.Status方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: logEndOfRequest
func logEndOfRequest(ctx context.Context, duration time.Duration, mw mutil.WriterProxy) {
log.Ctx(ctx).WithFields(log.F{
"status": mw.Status(),
"bytes": mw.BytesWritten(),
"duration": duration,
}).Info("Finished request")
}
示例2: printResponse
func (l *Logger) printResponse(w mutil.WriterProxy, delta time.Duration) {
var buf bytes.Buffer
buf.WriteString("Returning HTTP ")
status := w.Status()
if status < 200 {
colorWrite(&buf, bBlue, "%03d", status)
} else if status < 300 {
colorWrite(&buf, bGreen, "%03d", status)
} else if status < 400 {
colorWrite(&buf, bCyan, "%03d", status)
} else if status < 500 {
colorWrite(&buf, bYellow, "%03d", status)
} else {
colorWrite(&buf, bRed, "%03d", status)
}
buf.WriteString(" in ")
if delta < FastResponse {
colorWrite(&buf, nGreen, "%s", delta.String())
} else if delta < AcceptableResponse {
colorWrite(&buf, nYellow, "%s", delta.String())
} else {
colorWrite(&buf, nRed, "%s", delta.String())
}
log.Print(buf.String())
}
示例3: printEnd
func printEnd(reqID string, w mutil.WriterProxy, dt time.Duration) {
var buf bytes.Buffer
if reqID != "" {
cW(&buf, bBlack, "[%s] ", reqID)
}
buf.WriteString("Returning ")
status := w.Status()
if status < 200 {
cW(&buf, bBlue, "%03d", status)
} else if status < 300 {
cW(&buf, bGreen, "%03d", status)
} else if status < 400 {
cW(&buf, bCyan, "%03d", status)
} else if status < 500 {
cW(&buf, bYellow, "%03d", status)
} else {
cW(&buf, bRed, "%03d", status)
}
buf.WriteString(" in ")
if dt < 500*time.Millisecond {
cW(&buf, nGreen, "%s", dt)
} else if dt < 5*time.Second {
cW(&buf, nYellow, "%s", dt)
} else {
cW(&buf, nRed, "%s", dt)
}
logs.Debug(buf.String())
}
示例4: logEndOfRequest
func logEndOfRequest(ctx context.Context, duration time.Duration, mw mutil.WriterProxy) {
fields := logrus.Fields{
"status": mw.Status(),
"bytes": mw.BytesWritten(),
"duration": duration,
}
log.WithFields(ctx, fields).Info("Finished request")
}