-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathflash.go
More file actions
29 lines (23 loc) · 702 Bytes
/
flash.go
File metadata and controls
29 lines (23 loc) · 702 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package main
import (
`time`
`github.com/gorilla/sessions`
)
type TSSessionAlert struct {
Kind string `json:"kind"`
Message string `json:"message"`
ExpiresAt time.Time `json:"expires_at"`
ClearOnRead bool `json:"clear_on_read"`
}
func NewSessionAlert(kind string, message string, expires_at time.Time, clear_on_read bool) *TSSessionAlert {
return &TSSessionAlert{
Kind: kind,
Message: message,
ExpiresAt: expires_at,
ClearOnRead: clear_on_read,
}
}
type TSFlashMessages map[time.Time]*TSSessionAlert
func f_session_flash(session *sessions.Session, alert *TSSessionAlert) {
session.Values["flash"] = TSFlashMessages{time.Now().UTC(): alert}
}