Page:
ZH_Flash
Pages
Actions
Basicauth
Binding
Captcha
Compress
Context
Debug
Dispatch
ErrHandler
Events
Flash
Forms
Group
Handler
Home
Injection
Logger
Params
QuickStart
Recovery
Renders
Return
Router
Session
Static
Tango
Tpongo2
Xsrf
ZH_Actions
ZH_Basicauth
ZH_Binding
ZH_Captcha
ZH_Compress
ZH_Context
ZH_Debug
ZH_Dispatch
ZH_ErrHandler
ZH_Events
ZH_Flash
ZH_Forms
ZH_Group
ZH_HOME
ZH_Handler
ZH_Injection
ZH_Logger
ZH_Params
ZH_Recovery
ZH_Renders
ZH_Return
ZH_Router
ZH_Session
ZH_Static
ZH_Tango
ZH_Tpongo2
ZH_Xsrf
This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
Flash中间件为你在两次请求之间共享变量提供方便,他是一个 Tango 的中间件。
注意
此Flash版本已完全重写,目前基于 session 而不是cookie。老版本不再使用,因此和老版本有一定的不兼容。
安装
go get gitea.com/tango/flash
示例
import "gitea.com/tango/session"
type FlashAction struct {
flash.Flash
}
func (x *FlashAction) Get() {
x.Flash.Set("test", "test")
}
func (x *FlashAction) Post() {
x.Flash.Get("test").(string) == "test"
}
func main() {
t := tango.Classic()
sessions := session.Sessions()
t.Use(flash.Flashes(sessions))
t.Any("/", new(FlashAction))
t.Run()
}