Documentation ¶
Index ¶
- Constants
- type ContentProvider
- type ExecutionResult
- type Panel
- type PanelDataProvider
- type PanelProvider
- type Session
- func (sess *Session) HalftimePassed() bool
- func (sess *Session) HasExpired() bool
- func (sess *Session) IsUserLoggedIn() bool
- func (sess *Session) LoggedInUser() *SessionUser
- func (sess *Session) LoginUser(acc *data.Account, op *data.Operator)
- func (sess *Session) LogoutUser()
- func (sess *Session) Save(cookiePath string, w http.ResponseWriter)
- func (sess *Session) VerifyRequest(r *http.Request, verifyRemoteAddress bool) error
- type SessionManager
- type SessionUser
- type TemplateID
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 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.
func (*Session) IsUserLoggedIn ¶
IsUserLoggedIn tells whether a user is currently logged in.
func (*Session) LoggedInUser ¶
func (sess *Session) LoggedInUser() *SessionUser
LoggedInUser retrieves the currently logged in user or nil if none is logged in.
func (*Session) LogoutUser ¶
func (sess *Session) LogoutUser()
LogoutUser logs out the currently logged in user.
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.
type SessionUser ¶
SessionUser holds information about the logged in user.