Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func HTTPHandler ¶
HTTPHandler returns the main http.Handler.
func LoadSession ¶
func LoadSession(i *Interaction)
LoadSession is a handler step that loads the session or starts a new one if there is no valid session.
func ReadFormStateFromRequest ¶
func ReadFormStateFromRequest(i *Interaction)
ReadFormStateFromRequest is a handler step that initializes i.FormState from the incoming request. This is only suitable for POST handlers.
func SaveSession ¶
func SaveSession(i *Interaction)
SaveSession is a handler step that calls Interaction.SaveSession.
func UseEmptyFormState ¶
func UseEmptyFormState(i *Interaction)
UseEmptyFormState is a handler step that initializes an empty i.FormState.
Types ¶
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler allows to construct HTTP handlers by chained method calls describing the sequence of actions taken.
type HandlerStep ¶
type HandlerStep func(i *Interaction)
HandlerStep is a single step executed by a handler. When a handler step renders a result, it shall set i.Writer = nil to ensure that the remaining steps do not get executed.
func RedirectTo ¶
func RedirectTo(url string) HandlerStep
RedirectTo is a handler step that always redirects to the given URL.
func ShowForm ¶
func ShowForm(title string) HandlerStep
ShowForm is a final handler step that renders i.FormSpec with i.FormState.
func ShowFormIfErrors ¶
func ShowFormIfErrors(title string) HandlerStep
ShowFormIfErrors is like ShowForm, but only renders an output if i.FormState is not valid.
func ShowView ¶
func ShowView(view func(i *Interaction) Page) HandlerStep
ShowView is a final handler step that uses a callback to render the requested page.
func VerifyLogin ¶
func VerifyLogin(e core.Engine) HandlerStep
VerifyLogin is a handler step that checks the current session for a valid login, and redirects to /login if it cannot find one.
func VerifyPermissions ¶
func VerifyPermissions(perms core.Permissions) HandlerStep
VerifyPermissions is a handler step that checks whether the current user has at least the given permissions.
type Interaction ¶
type Interaction struct { Req *http.Request //Slots for data associated with a request, which may be stored by one step //and then used by later steps. Session *sessions.Session CurrentUser *core.UserWithPerms FormSpec *h.FormSpec FormState *h.FormState TargetUser *core.User //only used by CRUD views editing a single user TargetGroup *core.Group //only used by CRUD views editing a single group // contains filtered or unexported fields }
Interaction describes a single invocation of Handler.ServeHTTP().
func (*Interaction) RedirectTo ¶
func (i *Interaction) RedirectTo(url string)
RedirectTo redirects to the given URL.
func (*Interaction) RedirectWithFlashTo ¶
func (i *Interaction) RedirectWithFlashTo(url string, f Flash)
RedirectWithFlashTo is like RedirectTo, but stores a flash to show on the next page.
func (*Interaction) SaveSession ¶
func (i *Interaction) SaveSession() bool
SaveSession calls i.Session.Save(). When false is returned, a 500 error was written and the calling handler step shall abort immediately.
func (*Interaction) WriteError ¶
func (i *Interaction) WriteError(msg string, code int)
WriteError wraps http.Error().