lib

package
v0.0.0-...-d25348d Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2018 License: MPL-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ViewsDir is the directory where all the views are being stored.
	ViewsDir = "views"
)

Functions

func CheckError

func CheckError(res http.ResponseWriter, req *http.Request, err error) bool

CheckError returns true and sends the proper response if the given error is not nil. If the error is nil, then it just returns false and does nothing.

func DeleteCookie

func DeleteCookie(res http.ResponseWriter, req *http.Request, key string)

DeleteCookie deletes the specified cookie.

func GetCookie

func GetCookie(req *http.Request, name string) interface{}

GetCookie returns the value for the specified cookie. If the cookie does not exist, then an empty interface{} gets returned.

func GetStore

func GetStore(req *http.Request) *sessions.Session

GetStore tries to get the cookie store for the given request. It panics if it fails.

func InitSession

func InitSession()

InitSession initializes the global cookie store.

func JSONEncoding

func JSONEncoding(req *http.Request) bool

JSONEncoding returns true if we can assume that this is a JSON request, false otherwise.

func JSONError

func JSONError(res http.ResponseWriter)

JSONError sends the standard error for this application.

func Render

func Render(res http.ResponseWriter, name string, data interface{})

Render the view with the given name after evaluating the passed data. The rendered view will be written to the given writer.

func SetCookie

func SetCookie(res http.ResponseWriter, req *http.Request, key, value string)

SetCookie sets the given value to the specified cookie.

Types

type Response

type Response struct {
	Message string `json:"msg,omitempty"`
	Error   string `json:"error,omitempty"`
}

Response for short messages.

func (Response) String

func (r Response) String() string

Concatenate this response by marshalling it into JSON.

type ViewData

type ViewData struct {
	// The name of the javascript file to be used.
	JS string

	// The error message.
	Error string

	// Whether we are on print mode or not.
	Print bool
}

ViewData holds all the data that can be passed to a view.

func DefaultViewData

func DefaultViewData() *ViewData

DefaultViewData returns a ViewData object with the assets prefix set as expected.

Jump to

Keyboard shortcuts

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