本文整理汇总了Golang中github.com/zond/diplicity/common.HTTPContext.Secret方法的典型用法代码示例。如果您正苦于以下问题:Golang HTTPContext.Secret方法的具体用法?Golang HTTPContext.Secret怎么用?Golang HTTPContext.Secret使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/zond/diplicity/common.HTTPContext
的用法示例。
在下文中一共展示了HTTPContext.Secret方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: UnsubscribeEmails
func UnsubscribeEmails(c *common.HTTPContext) (err error) {
unsubTag, err := common.DecodeUnsubscribeTag(c.Secret(), c.Vars()["unsubscribe_tag"])
if err != nil {
return
}
u := &user.User{Id: unsubTag.U}
if err = c.DB().Get(u); err != nil {
return
}
switch unsubTag.T {
case common.UnsubscribeMessageEmail:
u.MessageEmailDisabled = true
case common.UnsubscribePhaseEmail:
u.MessageEmailDisabled = true
}
if err = c.DB().Set(u); err != nil {
return
}
switch unsubTag.T {
case common.UnsubscribeMessageEmail:
fmt.Fprintf(c.Resp(), "%v has successfully been unsubscribed from message emails.", u.Email)
case common.UnsubscribePhaseEmail:
fmt.Fprintf(c.Resp(), "%v has successfully been unsubscribed from phase emails.", u.Email)
}
return
}
示例2: Token
func Token(c *common.HTTPContext) (err error) {
if emailIf, found := c.Session().Values[common.SessionEmail]; found {
token := &gosubs.Token{
Principal: fmt.Sprint(emailIf),
Timeout: time.Now().Add(time.Second * 10),
}
if err = token.Encode(c.Secret()); err != nil {
return
}
err = c.RenderJSON(token)
} else {
err = c.RenderJSON(gosubs.Token{})
}
return
}