Documentation
¶
Index ¶
- Constants
- Variables
- func AddMessage(r *http.Request, tag MessageTag, message string, extraTags ...MessageTag) error
- func ConfigureBackend(initBackend func(r *http.Request) (MessageBackend, error))
- func Debug(r *http.Request, message string, extraTags ...MessageTag) error
- func Error(r *http.Request, message string, extraTags ...MessageTag) error
- func Info(r *http.Request, message string, extraTags ...MessageTag) error
- func MessagesMiddleware(next mux.Handler) mux.Handler
- func NewAppConfig() django.AppConfig
- func RequestMessageContext(c ctx.ContextWithRequest)
- func SetLevel(r *http.Request, level MessageTag) error
- func Success(r *http.Request, message string, extraTags ...MessageTag) error
- func Warning(r *http.Request, message string, extraTags ...MessageTag) error
- type BaseMessage
- type CookieBackend
- func (d *CookieBackend) Clear() error
- func (d *CookieBackend) Finalize(w http.ResponseWriter, r *http.Request) error
- func (d *CookieBackend) Get() (messages []Message, AllRetrieved bool)
- func (d *CookieBackend) Level() MessageTag
- func (d *CookieBackend) SetLevel(level MessageTag) error
- func (d *CookieBackend) Store(message Message) error
- type Message
- type MessageAppConfig
- type MessageBackend
- type MessageTag
- type MessageTags
- type SessionBackend
- func (b *SessionBackend) Clear() error
- func (b *SessionBackend) Finalize(w http.ResponseWriter, r *http.Request) error
- func (b *SessionBackend) Get() (msgs []Message, AllRetrieved bool)
- func (b *SessionBackend) Level() MessageTag
- func (b *SessionBackend) SetLevel(level MessageTag) error
- func (b *SessionBackend) Store(message Message) error
Constants ¶
View Source
const ( ErrRequestRequired = errs.Error("messages: request required") ErrBackendNotConfigured = errs.Error("messages: backend not configured") ErrMessagesNotInstalled = errs.Error("messages: app not installed") )
View Source
const ( DEBUG MessageTag = "debug" INFO MessageTag = "info" SUCCESS MessageTag = "success" WARNING MessageTag = "warning" ERROR MessageTag = "error" LEVEL_DEBUG uint = 10 LEVEL_INFO uint = 20 LEVEL_SUCCESS uint = 30 LEVEL_WARNING uint = 40 LEVEL_ERROR uint = 50 )
View Source
const (
APPVAR_COOKIE_KEY = "messages.cookieKey"
)
Variables ¶
View Source
var DefaultTags = MessageTags{ Debug: DEBUG, Info: INFO, Success: SUCCESS, Warning: WARNING, Error: ERROR, }
View Source
var LevelTags = map[uint]MessageTag{ LEVEL_DEBUG: DEBUG, LEVEL_INFO: INFO, LEVEL_SUCCESS: SUCCESS, LEVEL_WARNING: WARNING, LEVEL_ERROR: ERROR, }
View Source
var TagLevels = map[MessageTag]uint{ DEBUG: LEVEL_DEBUG, INFO: LEVEL_INFO, SUCCESS: LEVEL_SUCCESS, WARNING: LEVEL_WARNING, ERROR: LEVEL_ERROR, }
Functions ¶
func AddMessage ¶
func AddMessage(r *http.Request, tag MessageTag, message string, extraTags ...MessageTag) error
func ConfigureBackend ¶
func ConfigureBackend(initBackend func(r *http.Request) (MessageBackend, error))
func NewAppConfig ¶
func RequestMessageContext ¶
func RequestMessageContext(c ctx.ContextWithRequest)
Types ¶
type BaseMessage ¶
type BaseMessage struct { Level MessageTag `json:"tag"` Text string `json:"message"` ExtraLevels []MessageTag `json:"extra"` }
func (*BaseMessage) ExtraTags ¶
func (m *BaseMessage) ExtraTags() []MessageTag
func (*BaseMessage) Message ¶
func (m *BaseMessage) Message() string
func (*BaseMessage) Prepare ¶
func (m *BaseMessage) Prepare() error
func (*BaseMessage) String ¶
func (m *BaseMessage) String() string
func (*BaseMessage) Tag ¶
func (m *BaseMessage) Tag() MessageTag
type CookieBackend ¶
type CookieBackend struct { Request *http.Request BaseCookie *http.Cookie QueuedMessages []Message MinTagLevel uint // contains filtered or unexported fields }
func (*CookieBackend) Clear ¶
func (d *CookieBackend) Clear() error
func (*CookieBackend) Finalize ¶
func (d *CookieBackend) Finalize(w http.ResponseWriter, r *http.Request) error
func (*CookieBackend) Get ¶
func (d *CookieBackend) Get() (messages []Message, AllRetrieved bool)
func (*CookieBackend) Level ¶
func (d *CookieBackend) Level() MessageTag
func (*CookieBackend) SetLevel ¶
func (d *CookieBackend) SetLevel(level MessageTag) error
func (*CookieBackend) Store ¶
func (d *CookieBackend) Store(message Message) error
type Message ¶
type Message interface { Tag() MessageTag Message() string ExtraTags() []MessageTag Prepare() error }
type MessageAppConfig ¶
type MessageAppConfig struct { *apps.AppConfig Tags *MessageTags // contains filtered or unexported fields }
func (*MessageAppConfig) ConfigureBackend ¶
func (m *MessageAppConfig) ConfigureBackend(initBackend func(r *http.Request) (MessageBackend, error))
func (*MessageAppConfig) ConfigureTags ¶
func (m *MessageAppConfig) ConfigureTags(tags MessageTags)
type MessageBackend ¶
type MessageBackend interface { Get() (messages []Message, AllRetrieved bool) Store(message Message) error Level() MessageTag SetLevel(level MessageTag) error Finalize(w http.ResponseWriter, r *http.Request) error Clear() error }
func Backend ¶
func Backend(r *http.Request) MessageBackend
func BackendFromContext ¶
func BackendFromContext(r *http.Request) MessageBackend
func NewCookieBackend ¶
func NewCookieBackend(r *http.Request) (MessageBackend, error)
func NewSessionBackend ¶
func NewSessionBackend(r *http.Request) (MessageBackend, error)
type MessageTag ¶
type MessageTag string
type MessageTags ¶
type MessageTags struct { Debug MessageTag Info MessageTag Success MessageTag Warning MessageTag Error MessageTag }
func Tags ¶
func Tags() *MessageTags
type SessionBackend ¶
func (*SessionBackend) Clear ¶
func (b *SessionBackend) Clear() error
func (*SessionBackend) Finalize ¶
func (b *SessionBackend) Finalize(w http.ResponseWriter, r *http.Request) error
func (*SessionBackend) Get ¶
func (b *SessionBackend) Get() (msgs []Message, AllRetrieved bool)
func (*SessionBackend) Level ¶
func (b *SessionBackend) Level() MessageTag
func (*SessionBackend) SetLevel ¶
func (b *SessionBackend) SetLevel(level MessageTag) error
func (*SessionBackend) Store ¶
func (b *SessionBackend) Store(message Message) error
Click to show internal directories.
Click to hide internal directories.