本文整理匯總了Golang中github.com/cosiner/zerver.Response.ReportBadRequest方法的典型用法代碼示例。如果您正苦於以下問題:Golang Response.ReportBadRequest方法的具體用法?Golang Response.ReportBadRequest怎麽用?Golang Response.ReportBadRequest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/cosiner/zerver.Response
的用法示例。
在下文中一共展示了Response.ReportBadRequest方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Filter
func (ri *RequestId) Filter(req zerver.Request, resp zerver.Response, chain zerver.FilterChain) {
if req.Method() == "GET" {
chain(req, resp)
return
}
reqId := req.Header(ri.HeaderName)
if reqId == "" {
if ri.PassingOnNoId {
chain(req, resp)
} else {
resp.ReportBadRequest()
resp.Send("error", ri.Error)
}
} else {
id := req.RemoteIP() + ":" + reqId
if err := ri.Store.Save(id); err == ErrRequestIDExist {
resp.ReportForbidden()
resp.Send("error", ri.ErrorOverlap)
} else if err != nil {
ri.logger.Warnln(err)
} else {
chain(req, resp)
ri.Store.Remove(id)
}
}
}
示例2: Verify
// Verify xsrf token, used as zerver.FilterFunc
//
// The reason not use "Filter" as function name is to prevent the Xsrf from used as both Component and Filter
func (x *Xsrf) Verify(req zerver.Request, resp zerver.Response, chain zerver.FilterChain) {
if x.VerifyFor(req) {
chain(req, resp)
} else {
resp.ReportBadRequest()
resp.Send("error", x.Error)
}
}
示例3: Filter
func (j JSONP) Filter(req zerver.Request, resp zerver.Response, chain zerver.FilterChain) {
if req.Method() != "GET" {
chain(req, resp)
return
}
res, _ := req.ResourceMaster().Resource(resource.RES_JSON)
if res == nil {
resp.ReportNotAcceptable()
return
}
callback := req.Param(string(j))
if callback == "" {
resp.ReportBadRequest()
resp.Send("error", "no callback function")
return
}
resp.SetContentType(resource.RES_JSON, res)
_, err := resp.WriteString(callback)
if err != nil {
goto ERROR
}
_, err = resp.WriteString("(")
if err != nil {
goto ERROR
}
chain(req, resp)
_, err = resp.WriteString(")")
if err == nil {
return
}
ERROR:
req.Logger().Warnln(err)
}