本文整理匯總了Golang中github.com/cosiner/zerver.Response.Status方法的典型用法代碼示例。如果您正苦於以下問題:Golang Response.Status方法的具體用法?Golang Response.Status怎麽用?Golang Response.Status使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cosiner/zerver.Response
的用法示例。
在下文中一共展示了Response.Status方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: globalFilter
func globalFilter(req zerver.Request, resp zerver.Response, chain zerver.FilterChain) {
resp.SetContentType("text/plain", nil)
if resp.Status() == http.StatusNotFound {
resp.SetHeader("Location", path+"/options?from="+url.QueryEscape(req.URL().Path))
resp.ReportMovedPermanently()
} else if resp.Status() == http.StatusMethodNotAllowed {
resp.WriteString("The pprof interface only support GET request\n")
} else {
chain(req, resp)
}
}
示例2: Filter
func (l *Log) Filter(req zerver.Request, resp zerver.Response, chain zerver.FilterChain) {
if l.CountTime {
nano := time.Now().UnixNano()
chain(req, resp)
nano = time.Now().UnixNano() - nano
l.logger.Infoln(
time2.ToHuman(nano),
resp.Status(),
req.Method(),
req.URL().Path,
req.RemoteIP(),
req.UserAgent())
} else {
chain(req, resp)
l.logger.Infoln(
resp.Status(),
req.Method(),
req.URL().Path,
req.RemoteIP(),
req.UserAgent())
}
}
示例3: Filter
func (l *Log) Filter(req zerver.Request, resp zerver.Response, chain zerver.FilterChain) {
if l.CountTime {
now := time2.Now()
chain(req, resp)
cost := time2.Now().Sub(now)
l.logger.Infoln(
cost.String(),
resp.Status(),
req.Method(),
req.URL().Path,
req.RemoteIP(),
req.UserAgent())
} else {
chain(req, resp)
l.logger.Infoln(
resp.Status(),
req.Method(),
req.URL().Path,
req.RemoteIP(),
req.UserAgent())
}
}