Documentation
¶
Index ¶
Constants ¶
const ( // ContinueExecution causes the execution of a panel to continue. ContinueExecution = true // AbortExecution causes the execution of a panel to be aborted. AbortExecution = false )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ContentProvider ¶
type ContentProvider interface {
// GetTitle returns the title of the panel.
GetTitle() string
// GetCaption returns the caption which is displayed on the panel.
GetCaption() string
// GetContentJavaScript delivers additional JavaScript code.
GetContentJavaScript() string
// GetContentStyleSheet delivers additional stylesheet code.
GetContentStyleSheet() string
// GetContentBody delivers the actual body content.
GetContentBody() string
}
ContentProvider defines various methods for HTML content providers.
type ExecutionResult ¶
type ExecutionResult = bool
ExecutionResult is the type returned by the PreExecute function of PanelProvider.
type Panel ¶
type Panel struct {
// contains filtered or unexported fields
}
Panel provides basic HTML panel functionality.
func NewPanel ¶
func NewPanel(name string, provider PanelProvider, conf *config.Configuration, log *zerolog.Logger) (*Panel, error)
NewPanel creates a new panel.
func (*Panel) AddTemplate ¶
func (panel *Panel) AddTemplate(name TemplateID, provider ContentProvider) error
AddTemplate adds and compiles a new template.
func (*Panel) Execute ¶
func (panel *Panel) Execute(w http.ResponseWriter, r *http.Request, session *Session, dataProvider PanelDataProvider) error
Execute generates the HTTP output of the panel and writes it to the response writer.
type PanelDataProvider ¶
type PanelDataProvider = func(*Session) interface{}
PanelDataProvider is the function signature for panel data providers.
type PanelProvider ¶
type PanelProvider interface {
// GetActiveTemplate returns the name of the active template.
GetActiveTemplate(*Session, string) string
// PreExecute is called before the actual template is being executed.
PreExecute(*Session, string, http.ResponseWriter, *http.Request) (ExecutionResult, error)
}
PanelProvider handles general panel tasks.
type Session ¶
type Session struct {
ID string
MigrationID string
RemoteAddress string
CreationTime time.Time
Timeout time.Duration
LoggedInUser *data.Account
Data map[string]interface{}
// contains filtered or unexported fields
}
Session stores all data associated with an HTML session.
func NewSession ¶
NewSession creates a new session, giving it a random ID.
func (*Session) HalftimePassed ¶
HalftimePassed checks whether the session has passed the first half of its lifetime.
func (*Session) HasExpired ¶
HasExpired checks whether the session has reached is timeout.
type SessionManager ¶
type SessionManager struct {
// contains filtered or unexported fields
}
SessionManager manages HTML sessions.
func NewSessionManager ¶
func NewSessionManager(name string, conf *config.Configuration, log *zerolog.Logger) (*SessionManager, error)
NewSessionManager creates a new session manager.
func (*SessionManager) HandleRequest ¶
func (mngr *SessionManager) HandleRequest(w http.ResponseWriter, r *http.Request) (*Session, error)
HandleRequest performs all session-related tasks during an HTML request. Always returns a valid session object.
func (*SessionManager) PurgeSessions ¶
func (mngr *SessionManager) PurgeSessions()
PurgeSessions removes any expired sessions.