本文整理汇总了Golang中lib/wcg.Request.Header方法的典型用法代码示例。如果您正苦于以下问题:Golang Request.Header方法的具体用法?Golang Request.Header怎么用?Golang Request.Header使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lib/wcg.Request
的用法示例。
在下文中一共展示了Request.Header方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: getAPITokenHeader
func getAPITokenHeader(req *wcg.Request) string {
token := req.Header(request.APITokenHeader)
if wcg.IsUUID(token) {
return token
}
return ""
}
示例2: canSkipSessionMiddleware
func canSkipSessionMiddleware(req *wcg.Request) bool {
return req.Header(request.APITokenHeader) != "" ||
request.IsStatic(req) ||
request.IsHook(req) ||
request.IsCron(req) ||
request.IsTask(req)
}
示例3: debugger
func debugger(res *wcg.Response, req *wcg.Request) {
if !gates.CanPass(req, "debugger") {
return
}
if req.Header("x-ajax-request") == "true" {
// TODO: implement debugger here
}
}
示例4: NewTaskUser
// NewTaskUser creatse a *APITokenUser for the task
func NewTaskUser(req *wcg.Request) *APITokenUser {
return &APITokenUser{
&models.APIToken{
Token: "x-appengine-taskqueue",
Description: fmt.Sprintf(
"TaskName=%q, QueueName=%q",
req.Header("X-AppEngine-TaskName"),
req.Header("X-AppEngine-QueueName"),
),
CreatedAt: time.Now(),
AlertOn: time.Duration(0),
LastAccess: time.Now(),
},
}
}
示例5: authorizeByAPIToken
func authorizeByAPIToken(req *wcg.Request) {
tokenString := req.Header(request.APITokenHeader)
if !lib.IsOnGAE() && !lib.IsProduction() && tokenString == string(request.APITestUser.Token) {
req.User = request.APITestUser
return
}
if !wcg.IsUUID(tokenString) {
// Do not access APIToken entity if it's not a valid UUID.
return
}
_, ent, err := entities.APIToken.Get().Key(tokenString).Cache(true).One(req)
if err == nil {
req.User = &request.APITokenUser{ent.(*models.APIToken)}
return
}
}
示例6: IsTask
// IsTaskRequest returns true if the request is comming from TaskQueue.
func IsTask(req *wcg.Request) bool {
return req.Header(TaskQueueHeader) != ""
}
示例7: IsCron
// IsCronRequest returns true if the request is comming from cron.
func IsCron(req *wcg.Request) bool {
return strings.HasPrefix(req.URL().Path, CronPathPrefix) && req.Header(CronHeader) != ""
}