Documentation
¶
Index ¶
- func StartServer(templatesDir string, publicDir string, serverAddress string, ...)
- type AnyStorer
- type Context
- func (c *Context) AssignStorageMiddleware(rw web.ResponseWriter, req *web.Request, next web.NextMiddlewareFunc)
- func (c *Context) AssignTemplatesAndSessionsMiddleware(rw web.ResponseWriter, req *web.Request, next web.NextMiddlewareFunc)
- func (c *Context) CheckFailedRequestObject(rw web.ResponseWriter, req *web.Request) interface{}
- func (c *Context) GetErrorMessagesMiddleware(rw web.ResponseWriter, req *web.Request, next web.NextMiddlewareFunc)
- func (c *Context) GetNotificationMessagesMiddleware(rw web.ResponseWriter, req *web.Request, next web.NextMiddlewareFunc)
- func (c *Context) IndexHandler(rw web.ResponseWriter, req *web.Request)
- func (c *Context) SetErrorMessage(rw web.ResponseWriter, req *web.Request, err string)
- func (c *Context) SetFailedRequestObject(rw web.ResponseWriter, req *web.Request, requestedObject interface{})
- func (c *Context) SetNotificationMessage(rw web.ResponseWriter, req *web.Request, notification string)
- type URL
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AnyStorer ¶
type AnyStorer interface {
}
AnyStorer is the interface that is made up of all other storage interfaces
type Context ¶
type Context struct {
ErrorMessages []string
NotificationMessages []string
Data interface{}
Store *sessions.CookieStore
Storage AnyStorer
}
Context is used in all requests
func (*Context) AssignStorageMiddleware ¶
func (c *Context) AssignStorageMiddleware(rw web.ResponseWriter, req *web.Request, next web.NextMiddlewareFunc)
AssignStorageMiddleware creates the link to the storage
func (*Context) AssignTemplatesAndSessionsMiddleware ¶
func (c *Context) AssignTemplatesAndSessionsMiddleware(rw web.ResponseWriter, req *web.Request, next web.NextMiddlewareFunc)
AssignTemplatesAndSessionsMiddleware creates the context's link to the templates and sessions handlers
func (*Context) CheckFailedRequestObject ¶
func (c *Context) CheckFailedRequestObject(rw web.ResponseWriter, req *web.Request) interface{}
CheckFailedRequestObject returns just one "flash" failed request object for a session. Any other request objects that were stored will be removed without retrieval. It allows for users to amend bad forms without needing to retype all the data
func (*Context) GetErrorMessagesMiddleware ¶
func (c *Context) GetErrorMessagesMiddleware(rw web.ResponseWriter, req *web.Request, next web.NextMiddlewareFunc)
GetErrorMessagesMiddleware returns any flash error messages that have been saved. Upon retrieving them, they will be deleted from the session (as they are "flash" session variables)
func (*Context) GetNotificationMessagesMiddleware ¶
func (c *Context) GetNotificationMessagesMiddleware(rw web.ResponseWriter, req *web.Request, next web.NextMiddlewareFunc)
GetNotificationMessagesMiddleware returns any flash notification messages that have been saved. Upon retrieving them, they will be deleted from the session (as they are "flash" session variables)
func (*Context) IndexHandler ¶
func (c *Context) IndexHandler(rw web.ResponseWriter, req *web.Request)
IndexHandler is for serving the home/index page
func (*Context) SetErrorMessage ¶
SetErrorMessage allows for a handler to set an error message as a "Flash" message which can be shown to the user in a later request (via a different handler) - it stores them in a session variable
func (*Context) SetFailedRequestObject ¶
func (c *Context) SetFailedRequestObject(rw web.ResponseWriter, req *web.Request, requestedObject interface{})
SetFailedRequestObject allows us to store a bad request from a form (eg not meeting the regex for the NHI parameter of system.Patient) so it can be recalled later for them to amend it
func (*Context) SetNotificationMessage ¶
func (c *Context) SetNotificationMessage(rw web.ResponseWriter, req *web.Request, notification string)
SetNotificationMessage allows for a handler to set a notification message as a "Flash" message which can be shown to the user in a later request (via a different handler) - it stores them in a session variable
type URL ¶
type URL string
URL handles the urls in the application
const ( //IndexURL is used for the index/home page IndexURL URL = "/" //ViewURL is used when viewing a generated NPC ViewURL URL = "/view" //ViewSavedURL is used when viewing a saved NPC ViewSavedURL URL = "/view/:npcId" //SaveURL is used when saving the currently generated NPC SaveURL URL = "/save" )