本文整理匯總了Golang中github.com/cosiner/zerver.Request.URL方法的典型用法代碼示例。如果您正苦於以下問題:Golang Request.URL方法的具體用法?Golang Request.URL怎麽用?Golang Request.URL使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cosiner/zerver.Request
的用法示例。
在下文中一共展示了Request.URL方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: globalFilter
func globalFilter(req zerver.Request, resp zerver.Response, chain zerver.FilterChain) {
status := resp.StatusCode(0)
if status == http.StatusNotFound {
resp.Headers().Set("Location", path+"/options?from="+url.QueryEscape(req.URL().Path))
resp.StatusCode(http.StatusMovedPermanently)
} else if status == http.StatusMethodNotAllowed {
io2.WriteString(resp, "The pprof interface only support GET request\n")
} else {
chain(req, resp)
}
}
示例2: 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)
}
}
示例3: Filter
func (l *Log) Filter(req zerver.Request, resp zerver.Response, chain zerver.FilterChain) {
now := time2.Now()
chain(req, resp)
cost := time2.Now().Sub(now)
l.log.Info(log.M{
"method": req.ReqMethod(),
"url": req.URL().String(),
"remote": req.RemoteAddr(),
"userAgent": req.GetHeader(zerver.HEADER_USERAGENT),
"cost": cost.String(),
"statusCode": resp.StatusCode(0),
})
}
示例4: 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())
}
}
示例5: 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())
}
}