Documentation
¶
Index ¶
- Constants
- type Manager
- func (m *Manager) AsMessages(msg Message) []Message
- func (m *Manager) Error(ctx context.Context, content string, closeable bool, autoclose int)
- func (m *Manager) Get(ctx context.Context) Messages
- func (m *Manager) Info(ctx context.Context, content string, closeable bool, autoclose int)
- func (m *Manager) NewErrorMessage(content string, closeable bool, autoclose int) Message
- func (m *Manager) NewInfoMessage(content string, closeable bool, autoclose int) Message
- func (m *Manager) NewSuccessMessage(content string, closeable bool, autoclose int) Message
- func (m *Manager) NewWarningMessage(content string, closeable bool, autoclose int) Message
- func (m *Manager) ReplaceFlash(ctx context.Context, flashes Messages)
- func (m *Manager) Success(ctx context.Context, content string, closeable bool, autoclose int)
- func (m *Manager) Warning(ctx context.Context, content string, closeable bool, autoclose int)
- type Message
- type MessageType
- type Messages
Constants ¶
const SessionKey = "hop_session_flash"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager manages flash messages.
func NewManager ¶
func NewManager(session *scs.SessionManager) *Manager
NewManager creates a new Manager instance.
func (*Manager) AsMessages ¶
AsMessages ensures we have a slice of messages by converting a single message to a slice if necessary
func (*Manager) NewErrorMessage ¶
NewErrorMessage creates a new error flash message, but does not add it to the session.
func (*Manager) NewInfoMessage ¶
NewInfoMessage creates a new informational flash message, but does not add it to the session.
func (*Manager) NewSuccessMessage ¶
NewSuccessMessage creates a new success flash message, but does not add it to the session.
func (*Manager) NewWarningMessage ¶
NewWarningMessage creates a new warning flash message, but does not add it to the session.
func (*Manager) ReplaceFlash ¶
ReplaceFlash replaces the flash messages in the session.
type Message ¶
type Message struct {
Type MessageType // The type of message
Content string // The message to display
Closable bool // Closable by default; this flag makes it not closable
AutoClose int // Duration in milliseconds
}
Message represents a flash message.
func (Message) NotClosable ¶
NotClosable returns true if the flash message is not closable.
type MessageType ¶
type MessageType string
MessageType represents the type of flash message.
const ( // MessageTypeError is an error message MessageTypeError MessageType = "error" // MessageTypeSuccess is a success message MessageTypeSuccess MessageType = "success" // MessageTypeWarning is a warning message MessageTypeWarning MessageType = "warning" // MessageTypeInfo is an informational message MessageTypeInfo MessageType = "info" )