npcserver

package
v0.0.0-...-ebdd4af Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 2, 2017 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StartServer

func StartServer(templatesDir string, publicDir string, serverAddress string, cookieStoreSalt string)

StartServer is for starting the npc generation server

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

func (c *Context) SetErrorMessage(rw web.ResponseWriter, req *web.Request, err string)

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"
)

func (URL) Make

func (u URL) Make(param ...string) string

Make creates a URL

func (URL) String

func (u URL) String() string

String returns the URL as a string (to satisfy the Stringer interface)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
⌂ 换网址